SQL Server 中截取字符串常用的函數: 1.LEFT ( character_expression , integer_expression ) 函數說明:LEFT ( '源字符串' , '要截取最左邊的字符數' ) 返回從字符串左邊開始指定個數的字符 select LEFT('SQL_Server_2008',4 ); 返回結果:SQL_ 2.RIGHT ( character_expression , integer_expression ) 函數說明:RIGHT ( '源字符串' , '要截取最右邊的字符數' ) 返回字符串中從右邊開始指定個數的 integer_expression 字符 select RIGHT('SQL_Server_2008',4 ); 返回結果:2008 3.SUBSTRING ( character_expression , start , length ) 函數說明:SUBSTRING ( '源字符串' , '截取起始位置(含該位置上的字符)' , '截取長度' ) 返回字符、binary、text 或 image 表達式的一部分 select SUBSTRING('SQL_Server_2008',5 ,6); 返回結果:Server
http://blog.csdn.net/hu_shengyang/article/details/10536881 轉載地址