当我运行一个SQL将我的数据类型值从varchar
转换为datetime
时,我一直遇到以下错误:
Msg 242,级别16,状态3,第1行 将varchar数据类型转换为datetime数据类型导致超出范围的值。
我已经检查了数据,但没有发现任何问题:运行以下检查并全部未返回结果
SELECT [Date] from table where [DATe] is null
SELECT [Date] from table where [DATe] = ''
SELECT [Date] from table where LEN([date])> 10
SELECT [Date] from table where LEN([date])< 10
SELECT top 100 [Date] , SUBSTRING([date],4,2) from [table where convert(int, SUBSTRING([date],4,2)) < 1 or convert(int, SUBSTRING([date],4,2)) > 12
SELECT top 100 [Date] , SUBSTRING([date],1,2) from table where convert(int, SUBSTRING([date],4,2)) < 1 or convert(int, SUBSTRING([date],4,2)) > 31
还有什么其他值得关注的地方,也许需要一些建议或帮助解决这个问题?似乎无法找到问题的根源。