22,209
社区成员
发帖
与我相关
我的任务
分享
--字符和数字会进行隐式转换,如果转换不过去,自然会报错。
--这样,肯定会报错。
select * from table where A='a'
create table tb(A int)
insert tb select 1
select * from tb where cast(A as varbinary)=cast(1 as varbinary)
/*
A
-----------
1
*/
(1 行受影响)
select * from tb where cast(A as varbinary)=cast('1' as varbinary)
/*
A
-----------
(0 行受影响)
*/
create table tb(A int)
insert tb select 1
select * from tb where cast(A as varbinary)=cast(1 as varbinary)
A
-----------
1
(1 行受影响)
select * from tb where cast(A as varbinary)=cast('1' as varbinary)
A
-----------
(0 行受影响)