SQL截图字符串

  1. SQL Server 中截取字符串常用的函数:  
  2.   
  3. 1.LEFT ( character_expression , integer_expression )  
  4. 函数说明:LEFT ( '源字符串' , '要截取最左边的字符数'  )  
  5. 返回从字符串左边开始指定个数的字符  
  6. select LEFT('SQL_Server_2008',4 );  
  7. 返回结果:SQL_  
  8.   
  9.   
  10. 2.RIGHT ( character_expression , integer_expression )  
  11. 函数说明:RIGHT ( '源字符串' , '要截取最右边的字符数'  )  
  12. 返回字符串中从右边开始指定个数的 integer_expression 字符  
  13. select RIGHT('SQL_Server_2008',4 );  
  14. 返回结果:2008  
  15.   
  16.   
  17. 3.SUBSTRING ( character_expression , start , length )  
  18. 函数说明:SUBSTRING ( '源字符串' , '截取起始位置(含该位置上的字符)' , '截取长度' )  
  19. 返回字符、binary、text 或 image 表达式的一部分  
  20. select SUBSTRING('SQL_Server_2008',5 ,6);  
  21. 返回结果:Server  
  22. 参考来源地址:http://blog.csdn.net/hu_shengyang/article/details/10536881

猜你喜欢

转载自blog.csdn.net/qq_28135179/article/details/80206710