sql server中的怎么把数值型转换为字符串
①select cast(字段 as varchar) from 表名
②select convert(varchar(50),字段) from 表名
标签: SQL
select * from ppegeneral
–update ppegeneral set itempara=convert(varchar(50),(convert(numeric(6,2),itempara)-1))
where techno=‘du’ and itemname like ‘%镀铜电流密度(ASF) %’
and pdctno in (select max(pdctno) from ppeflow group by left(pdctno,7))
and pdctno in (select pdctno from mktdelivery where convert(char(10),indate,120)>‘2017-08-01’)
and itempara<>‘/ ’ and itempara not in (’ ‘,’/’,‘0’)
and left(pdctno,1)>‘8’
order by itempara desc
select pdctno into #ppe01 from ppegeneral
–update ppegeneral set itempara=convert(varchar(50),(convert(numeric(6,2),itempara)-1))
where techno=‘du’ and itemname like ‘%镀铜电流密度(ASF) %’
and pdctno in (select max(pdctno) from ppeflow group by left(pdctno,7))
and pdctno in (select pdctno from mktdelivery where convert(char(10),indate,120)>‘2017-08-01’)
and itempara<>‘/ ’ and itempara not in (’ ‘,’/’,‘0’)
and left(pdctno,1)>‘8’
①select cast(字段 as varchar) from 表名
②select convert(varchar(50),字段) from 表名
convert(varchar(50),(convert(numeric(6,2),itempara)-1))

有的时候我们做数据库查询时需要将某个字符型字段转换成数值型 字段进行比较,如果直接比较的话就会出错,需要将士字符型字段转换成数值型。
方法很简单,SELECT *FROM 表 Where cast(字符型字段名 as float)>100
以上即把字符型字段转换成了float型进行查询比较。