SQL SERVLER 系统函数(二)字符串函数
来源:互联网 发布:cs1.6 mac版下载地址 编辑:程序博客网 时间:2024/06/06 15:42
Sql Server 中常用的字符串函数:
● SubString(string,starting position,length):返回字符串的一部分。
select substring('abcdefg',3,2) as teststring
执行结果
teststring
-------
cd
● Stuff(string,insertion position,delete count,string inserted):substring函数相反。
select Stuff('abcdefg',3,2,'123') as teststring
执行结果
teststring
-------
ab123cdefg
● CharIndex(search string,string,starting postion):返回一个字符串在另一个字符串中的起始位置。
select CharIndex('c','abcdefg',1) as teststring
执行结果
teststring
-------
3
● Right(string,count)和Left(string,count):返回指定字符串从最右边或者最左边开始指定个数的字符。
select Left('Nielsen',2) as [Left],Right('Nielsen',2) as [Right]
执行结果
Left Right
-----------------
Ni en
● Len(string):返回指定字符串的长度。
select Len('abcdefg') as teststring
执行结果
teststring
-------
7
● Rtrim(string)和Ltrim(string):删除起始或者尾随的空格。
select Rtrim(' abcdefg ') as [Rtrim],Ltrim(' abcdefg ') as [Ltrim]
执行结果
Rtrim Ltrim
--------------------
**abcdefg abcdefg** *代表空格,以便区别
● Upper(string)和Lower(string):将整个字符串转换为大写或者小写。
select Upper('abcd') as [Upper],Lower('ABCD') as [Lower]
执行结果
Upper Lower
--------------------
ABCD abcd
● Replace(source,search,replace):replace()函数在一个字符串中搜索指定的字符串,并用另一个字符串来替代它。
select Replace('abcdefg','abc','***') as teststring
执行结果
teststring
-------
***defg
● SubString(string,starting position,length):返回字符串的一部分。
select substring('abcdefg',3,2) as teststring
执行结果
teststring
-------
cd
● Stuff(string,insertion position,delete count,string inserted):substring函数相反。
select Stuff('abcdefg',3,2,'123') as teststring
执行结果
teststring
-------
ab123cdefg
● CharIndex(search string,string,starting postion):返回一个字符串在另一个字符串中的起始位置。
select CharIndex('c','abcdefg',1) as teststring
执行结果
teststring
-------
3
● Right(string,count)和Left(string,count):返回指定字符串从最右边或者最左边开始指定个数的字符。
select Left('Nielsen',2) as [Left],Right('Nielsen',2) as [Right]
执行结果
Left Right
-----------------
Ni en
● Len(string):返回指定字符串的长度。
select Len('abcdefg') as teststring
执行结果
teststring
-------
7
● Rtrim(string)和Ltrim(string):删除起始或者尾随的空格。
select Rtrim(' abcdefg ') as [Rtrim],Ltrim(' abcdefg ') as [Ltrim]
执行结果
Rtrim Ltrim
--------------------
**abcdefg abcdefg** *代表空格,以便区别
● Upper(string)和Lower(string):将整个字符串转换为大写或者小写。
select Upper('abcd') as [Upper],Lower('ABCD') as [Lower]
执行结果
Upper Lower
--------------------
ABCD abcd
● Replace(source,search,replace):replace()函数在一个字符串中搜索指定的字符串,并用另一个字符串来替代它。
select Replace('abcdefg','abc','***') as teststring
执行结果
teststring
-------
***defg
- SQL SERVLER 系统函数(二)字符串函数
- SQL SERVLER 系统函数(一)日期函数
- SQL Server 字符串 系统常用函数 贴心
- 字符串函数(二)
- SQL字符串函数
- SQL常用字符串函数
- SQL常用字符串函数
- 常用SQL字符串函数
- SQL的字符串函数
- 常用SQL字符串函数
- SQL 字符串分割函数
- SQL字符串函数
- sql字符串处理函数
- SQL常用字符串函数
- 【转】SQL字符串函数
- sQL 连接字符串 函数
- SQL常用字符串函数
- SQL常用字符串函数
- SQLServer和Oracle常用函数对比
- 如何使得执行scp命令时不需要输入用户密码
- IsPostBack深入探讨
- 监听一个文件的改变(1秒一次)
- QTestWare升级到1.1版本了!
- SQL SERVLER 系统函数(二)字符串函数
- DataView的用法
- Dynamically Created Controls - Common Pitfalls (动态控件易出现的问题)
- 只能输入数字的文本框,且不能粘贴
- 项"Oracle"已添加,或者The entry "*" has already been added的解决方法
- 常用正则表达式大全
- 浅入浅出Liunx Shellcode(安全焦点)
- 使用C#实现Windows下无焦点窗体
- 从虚拟机中制做ubuntu liveusb