方法一: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
获取工作日 需要编写一个SqlServer函数,F_getWorkday,传入两个参数,第一个为时间date,第二个参数为第几个工作日num.调用F_getWorkday后返回date之后的第num个工作日. 现有节假日安排表如下: drop function [dbo].[F_getWorkday]; create function [dbo].[F_getWorkday]( @staDate datetime, @workDay int ) returns datetime as begin
1.绝对值 S:select abs(-1) value O:select abs(-1) value from dual 2.取整(大) S:select ceiling(-1.001) value O:select ceil(-1.001) value from dual 3.取整(小) S:select floor(-1.001) value O:select floor(-1.001) value from dual 4.取整(截取) S:select cast(-1.002 as in
函数基本功能: 转换工厂日期,将8点20之前的时间转化为前一天的时间. if exists (select * from sysobjects where xtype='fn' and name='FacTimeTrans') drop function dbo.FacTimeTrans go Create Function dbo.FacTimeTrans(@begintime datetime) ) as begin ) ),) < '08:20:00') ),,) else ),) ret
CREATE FUNCTION getsort (@first varchar(100),@second varchar(100))RETURNS intASBEGIN declare @rv int if(@first=@second) set @rv=1 elseset @rv=0 -- Return the result of the function RETURN @rv ENDGO