card_type char字段
other2 varchar字段select * from pos_vip_info where convert(int,card_type) > 1这个可以把这个字段大于1的都显示出来了select * from pos_vip_info where convert(int,other2) > 1
为什么这个就没有结果
select * from pos_vip_info where convert(int,other2) > 1 and convert(int,card_type) > 1这个更没有结果,请高手给我说一下这句的正确方法!
other2 varchar字段select * from pos_vip_info where convert(int,card_type) > 1这个可以把这个字段大于1的都显示出来了select * from pos_vip_info where convert(int,other2) > 1
为什么这个就没有结果
select * from pos_vip_info where convert(int,other2) > 1 and convert(int,card_type) > 1这个更没有结果,请高手给我说一下这句的正确方法!
other2 varchar字段 这里面存的是 123.4520 这样的小数,还有一些是空的两个里面都没有数字以外的字符...
create table pos_vip_info
(
card_type char(10),
other2 varchar(10)
)
insert pos_vip_info
select '01','123.5' union all
select '02','15.623' union all
select '03','0.5' union all
select '04','13.5'select * from pos_vip_info where convert(int , card_type)>1
/*
card_type other2
---------- ----------
02 15.623
03 0.5
04 13.5(3 行受影响)*/
select * from pos_vip_info where convert(int , other2)>1
/*
-----------
card_type other2
---------- ----------
消息 245,级别 16,状态 1,第 2 行
在将 varchar 值 '123.5' 转换成数据类型 int 时失败。
*/select * from pos_vip_info where convert(numeric , other2)>1
/*
card_type other2
---------- ----------
01 123.5
02 15.623
04 13.5(3 行受影响)*/
go
drop table pos_vip_info