================字符串使用汇总================
--将字符串中从某个字符开始截取一段字符,然后将另外一个字符串插入此处
select stuff('hello,world!',4,4,'****') --返回值hel****orld!
--返回从指定位置开始指定长度的字符串
select substring('Hello,World!',2,10) --返回值ello,World
--将字符串中某段字符替换为指定的字符串
select replace('hello,world!','ll','aa') --返回值heaao,world!
--去除字符串中左边的空格
select ltrim(' hello,world!') --返回值hello,world!
--去除字符串中左边的空格
select ltrim('hello,world! ') --返回值hello,world!
--去除字符串中左边和右边的空格
select ltrim(' hello,world! ') --返回值hello,world!
--将NULL值替换为指定字符
select isnull('a',null) --返回值a
--转换数据类型
select cast('2007-10-11' as datetime) --返回值2007-10-11 00:00:00.000
select convert(datetime,'2007-10-11') --返回值2007-10-11 00:00:00.000
--获取字符串长度
select len('hello,world!') --返回值12