sqlserver 截取两个固定字符串之间的值

来源:互联网 发布:筑巢软件上班怎么样 编辑:程序博客网 时间:2024/06/07 00:35

语法:SUBSTRING ( expression, start, length )

语法:CHARINDEX ( expression1 , expression2 [ , start_location ] )

Expression1是要到expression2中寻找的字符中,start_location是CHARINDEX函数开始在expression2中找expression1的位置。



结果:
select substring('2016年10月',charindex('年','2016年10月')+1,
charindex('月','2016年10月')-charindex('年','2016年10月')-1) from db_FCXXB