Want to capture the school, how should do? Length of uncertainty in front of the school, the school is not sure
CodePudding user response:
Intercept "graduate" and a comma between the charactersCodePudding user response:
Write a function to deal with, so long as regularCodePudding user response:
if not object_id (' school ') is null
Drop table school
Go
The Create table school ([Student] nvarchar (2), [introduce] nvarchar (100))
Insert school
Select N 'Joe', N 'in 1988, graduated from anhui university of finance and economics' union all
Select N 'Cathy', N '1988 graduated from south China normal university education professional' union all
Select N 'bill', N 'professional graduated from Beijing university in 1988 linguistics'
Select substring (school, 4, charindex (' learn 'school)) as the from school (
Select
The SUBSTRING (introduce, charindex (' graduate, introduce), charindex (' university, introduce) - charindex (' graduate, introduce)) + 'university' as school
The from school) t1