문제

I've got a SELECT that gets, among other things,

CONVERT(varchar(10), TIMESTAMP)

where TimeStamp is defined as

[TIMESTAMP] [binary](8) NULL

Some of the timestamps have bad data, meaning instead of something like 0x30332F31372F3131, which converts to "03/17/11", they have only the bottom four bytes, as in 0x0000000002F09ADD.

When I do the SELECT in an MSSMS query window those bad ones come out blank, which is fine, but when I retrieve them in my program using an SqlDataReader the Strings for the bad timestamps come out with garbage characters, as in " ðšÝ".

Any ideas as to what I can do about this?

도움이 되었습니까?

해결책

Select case when ISDate(CONVERT(varchar(10), TIMESTAMP))=1 then CONVERT(varchar(10), TIMESTAMP) else null end 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top