티스토리 뷰
데이터가 얼마 없을때는 무리없이 잘 돌던게..
쿼리 대상 데이터가 많아지자 아래와 같은 에러메세지를 가뿐히 보여주며 문제가 생겼댄다.
Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
어우..
머가 문젤까.. 진짜 고민 많이 했다.
getDate()를 문자로 convert하고 다시 datetime으로 변환하면 잘 되드만..
여기저기 검색해본 결과 아래와 같은 mssql server helper라는 사이트를 찾았다.
이유인 즉슨.. 데이터들중에 valid하지 않은 값이 있었다.
예를 들면.. 20091000121212 이런경우에..
날짜는 0일이라는게 없지 않은가..
걍 알아서 변환 잘 좀 해주지.. 싶지만.. 모.. 그걸 규칙없이 처리해줄리도 만무하고..
결국은 ISDATE( 'YYYYMMDD hh:mm:ss') 라는 함수를 찾아냈다.
블아보!
이 함수는 해당 값이 유효한 값인지 판별 한 이후에,
유효한 값이면 1을, 유효하지 않으면 0을 토해낸다.
[아래출처 : http://www.sql-server-helper.com/error-messages/msg-242.aspx]
SQL Server Error Messages > Msg 242 - The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
SQL Server Error Messages - Msg 242 - The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. | |||
To illustrate, the following SELECT statements will generate the error: SELECT CAST('02/29/2006' AS DATETIME) -- 2006 Not a Leap Year Another way the error may be encountered is when the format of the date string does not conform to the format expected by SQL Server as set in the SET DATEFORMAT command. To illustrate, if the date format expected by SQL Server is in the MM-DD-YYYY format, the following statement will generate the error: SELECT CAST('31-01-2006' AS DATETIME) |
'Computer > Databases' 카테고리의 다른 글
[MSSQL] Constraint 때문에 Alter / Drop 실행이 안될때.. (0) | 2009.11.20 |
---|---|
[MSSQL] DATEDIFF (0) | 2009.11.12 |
[MSSQL2005] YYYYMMDDHHMISS형태의 날짜 String 을 Datetime으로 (0) | 2009.10.08 |
[MSSQL] REPLACE (0) | 2009.09.23 |
[SQL문] INSERT INTO SELECT문 (0) | 2009.09.16 |
- Total
- Today
- Yesterday
- MySQL
- 새희망씨앗 피해자
- 와코마리아
- 라고스
- 부드러운맛
- 단체소송
- UML
- eclipse
- 해외직구
- javascript
- 기부피해
- java
- 나이지리아
- VirtureBox
- 새희망씨앗
- 팸세일
- 6월 패밀리세일
- 마라탕 #마라상궈 #마라탕재료 #쉽게만드는마라탕 #중딩입맛 #마라탕잡탕
- 안드로이드
- 인도
- 와코마리아 스웨터
- 리터너블
- 와코마리아한남동
- 패밀리세일
- 한남동세일
- 사업자등록
- 와코마리아팸세일
- 기부사기
- 홈택스
- 페밀리세일
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |