例如,第一个知道的是发生日期,下一个单词是Type。发生日期:2013年10月14日
在这个例子中,我需要日期10/14/2013
这是我到目前为止掌握的代码
substring(shortnote,charindex('occurance date:', shortnote),charindex('type',shortnote) - charindex('occurance date:', shortnote) -len('type'))发布于 2014-03-28 17:24:36
您可以将整个逻辑建立在开始模式的基础上,并使用PATINDEX解决这个问题。
有点像
DECLARE @VAR VARCHAR(100)
SET @VAR='asdfasdfasfasdfasfa asasfd Occurance Date: 10/14/2013 type: drug physician xyz'
DECLARE @Begin_Pattern VARCHAR(100)
SET @Begin_Pattern='Occurance Date: '
SELECT SUBSTRING(@VAR,(PATINDEX('%Occurance Date: %',@VAR)+LEN(@Begin_Pattern)),11)https://stackoverflow.com/questions/22719098
复制相似问题