--字符串功能
--substring
print substring('iamagoodperson',1,0)">5)
select 5)
--upper
upper('he is a good person')
--lower
LOWER('this is an VERY interesting job')
--ltrim
ltrim(' i am a good person')
--rtrim
rtrim(' heihei,i do not kNow why it likes this ')
--replace
replace('iwanttoaskyou','ttoa',0)">'i love you')
--stuff
stuff('我的名字是朱旭杰',0)">6,0)">8,0)">'summer')
--Date/Time Fuction
--getdate()
getdate() as 'today'
--dateadd()
dateadd(yy,0)">10,255)">getdate())
--datediff()
datediff(yy,0)">'1982/5/3',255)">getdate()) as
--datepart()
datepart(dw,255)">getdate())
datepart(yy,255)">datepart(mm,255)">datepart(dd,255)">datepart(ss,255)">datepart(ms,0)">'1982/5/3')
'1982/8/22')
--day(),相当于datepart(dd,128)">时间)
day(getdate())
--month(),128)">datepart(mm,255)">month(getdate())
--year(),128)">datepart(yy,255)">year(数学函数
--abs()
abs(-100.3456)
--sin()
sin(0.54)
--cos()
cos(3.14)
--power()
power(2)
--round 返回数字表达式并四舍五入为指定的长度或精度
round(100.45,0)">1)
123,0)">45,128)">--floor()
floor(4.9)
123.99)
--ceiling()
ceiling(--sqrt()
sqrt(100)
--square
square(10)
15)
转换函数
--cast()
cast(100.45 as int)
1345 varchar(10))
--convert()
convert(int,0)">100.56)
10),0)">2345)
空值函数
--isnull()
declare @temp_table table
(
bookID VARCHAR(10) primary key,
book_price float default null,
bookName 50)
)
insert into values('1',0)">50,0)">'c#')
'2',null ,0)">'c')
select bookID AS 书的编号isnull(book_price,0)">0) 书的价格'
from @temp_table
--nullif(),128)">只要参数里的两个表达式相同就返回null
nullif('iam',0)">'iam')
--coalesce返回其参数中第一个非空表达式
coalesce('i am a good boy')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。