SQLserver 查询常用的函数

日期转换 

Convert(类型长度,Date,格式)

实例:Convert(char(10),‘2018-01-30 09:42:00.521’,23)  会得到  2018-01-30

格式有很多可以专门去查sqlserver日期转换的格式,个人常用的格式

23:yyyy-MM-dd,112:yyyyMMdd,110:MM-dd-yyy,108: hh:mm:ss 

字符串转换为金额

cast(字符串 as money) 或者 convert(money,字符串)

为空转换0

isnull(数值,0)

去重复

distinct()

去空格

LTRIM()  把字符串头部的空格去掉。

RTRIM() 把字符串尾部的空格去掉。

猜你喜欢

转载自blog.csdn.net/weixin_42236021/article/details/80688303