方法一:convert(float,字段名) as 别名 select convert(float,round(10.123232,2)) 结果:10.12 select convert(float,round(10,2)) 结果:10 方法二:cast(round(字段名,2) as numeric(20,2)) as 别名 select cast(round(10.123232,2) as numeric(20,2)) 结果:10.12 select cast(round(10,2) as
日期和时间数据的处理. (1)字符串日期 ‘20080301’,这一串为字符串日期,但必须保证为四位的年份,两位的月份,两位的日期.例如,查询订单表日期大于‘20080301’.可以这样写: 1 select * from sales.orders 2 where orderdate>'20080301' 结果如图所示: (2)cast进行转化.例如,可以讲‘20080301’转化为时间类型.其结果跟上图一样. 1 select * from sales.orders 2 where order
) SET @Name = '\EXAM\061023478874' DECLARE @Position INT --sql first indexof SET @Position = CHARINDEX('.', @Name); ,LEN(@Name)-@Position) --sql last indexof ,LEN(@Name)-@Position)
方法一:convert(float,字段名) as 别名 select convert(float,round(10.123232,2)) 结果:10.12 select convert(float,round(10,2)) 结果:10 方法二:cast(round(字段名,2) as numeric(20,2)) as 别名 select cast(round(10.123232,2) as numeric(20,2)) 结果:10.12 select cast(round(10,2) as
Ma,LeiTo(Ma,lT) 分割后为 姓 名 Ma,LeiTo Ma,lT SELECT LEFT(作者, CHARINDEX('(', 作者) - 1) AS 姓 , replace( STUFF(作者,1, CHARINDEX('(', 作者) , ''),')','') AS 名 ,* FROM 作者表 删除最大值 delete from 表 where id in( SELECT id FROM dbo.表 T WHERE EXISTS (SELECT name F