我有一个表accounts
,其中col
列的类型为nvarchar(20)
select col from accounts where col='12'
返回
12
但是当我查询时
select col from accounts where cast(col as float)=12
它返回
将数据类型nvarchar转换为float时出错。
插入临时表后,它正常工作
select col into #tmp from accounts where col ='12'
select * from #tmp where cast(col as float)=12
为什么我会收到此错误?