开发者

SQL Server Strings and Dates

Have an annoying issue with Microsoft trying the be too clever again, when I query my database and a value such as 2/2 is returned in a nvarchar field it automatically decides this is a date and should instead be 02-Feb which is no fun when its the first line of an address!

This is in SQL Server Management Studio.

Any Ideas?

My Code开发者_开发百科 is as follows:

SELECT LTRIM(ISNULL(FlatNo+case when LEN(FLATNO) < 1 then '' else ' ' end,' ')
+ISNULL(Building+case when LEN(Building) < 1 then '' else ' ' end,' ')
+ISNULL(Line1+case when LEN(Line2) < 1 then '' else CHAR(10)+CHAR(13) end,' ')
+ISNULL(Line2+case when LEN(Line3) < 1 then '' else CHAR(10)+CHAR(13) end,' ')
+ISNULL(Line3,' ')) AS MailingAddress
FROM [Address]

This issue is cropping up in the first field, 'FlatNo'

The value in the field being converted is '2/2'


Check all apps that have touched the data! Excel converts dates in the manor described above, this was my issue.

Thanks to all of you who helped!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜