SQL Server字符串函数的描述


  本文标签:SQL Server字符串函数

  以下的文章主要向大家讲述的是SQL Server字符串函数,以及对其实际操作代码的描述,以下就是具体方案的描述,希望在你今后的学习中会有所帮助,如果你对其相关的实际操作有兴趣了解的话,以下的文章将会给你提供相关的知识  。

  select ascii(123) as 123,ascii(123) as "123",ascii(abc) as "abc" --转换成ascii码

  select char(123),char(321),char(-123) --根据ascii转换成字符

  select lower(ABC),lower(Abc),upper(Abc),upper(abc) --转换大小写

  select str(123.45,6,1), str(123.45,2,2) --把数值转换成字符串

  select ltrim( "左边没有空格") --去空格

  select rtrim("右边没有空格" ) --去空格

  select ltrim(rtrim( "左右都没有空格" )) --去空格

  select left(sql server,3),right(sql server,6) --取左或者取右

  use pubs

  select au_lname,substring(au_fname,1,1) --取子串

  from authors

  order by au_lname

  select charindex(123,abc123def,2) --返回字符串中指定表达式的起始位置

  select patindex(123,abc123def),patindex(%123%,abc123def) --返回表达式中某模式第一次出现的起始位置

  select quotename(abc,{),quotename(abc) --返回由指定字符扩住的字符串

  select reverse(abc),reverse(上海) --颠倒字符串顺序

  select replace(abcdefghicde,cde,xxxx) --返回呗替换了指定子串的字符串

  select space(5),space(-2)

  以上的相关内容就是对SQL Server字符串函数的介绍,望你能有所收获  。