Sql Server 中常用的字符串函数
来源:互联网 发布:win10 杀毒软件 知乎 编辑:程序博客网 时间:2024/05/21 22:32
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
- Sql Server 中常用的字符串函数
- SQL Server 中截取字符串常用的函数
- SQL Server 中截取字符串常用的函数
- SQL Server 中截取字符串常用的函数
- SQL Server中截取字符串常用函数
- SQL Server中截取字符串常用函数
- SQL Server中截取字符串常用函数
- SQL Server中截取字符串常用函数
- SQL Server处理字符串常用的函数
- SQL SERVER 常用字符串函数
- SQL server常用的字符串函数、日期函数、数学函数;
- SQL Server中截取字符串的函数
- SQL Server中常用的函数。
- sql server中常用的几个函数
- sql server 中常用的日期函数
- 列举SQL Server中常用的函数
- SQL SERVER 截取字符串常用函数
- SQL Server 字符串 系统常用函数 贴心
- SQLServer2000同步复制技术实现步骤
- object sender,EventArgs e的一些讲解
- 经典名言
- 设置按钮控件字体
- 把窗体或控件保存为图片
- Sql Server 中常用的字符串函数
- Cannot start ECMT Manager(Symbian 模拟器)
- SQL Server 2008 对 T-SQL 语言的增强
- 中文乱码终极篇
- 关于freetds连接微软SQL Server的注意事项
- 关于在oracle数据库如何增大连接的处理
- 用命令打开控制面板的各项
- 字节对齐
- Windows系统:开始–运行–命令大全