想要截取学校,应该怎么搞?学校前面的不确定,学校长度也不确定

解决方案 »

  1.   

     if not object_id('school') is null
        drop table school
    Go
    Create table school([Student] nvarchar(2),[introduce] nvarchar(100))
    Insert school
    select N'张三',N'1988年毕业于安徽财经大学经济学专业' union all
    select N'王五',N'1988年毕业于华南师范大学教育学专业' union all
    select N'李四',N'1988年毕业于北京大学语言学专业'select substring(学校,4,charindex('学',学校)) as 学校 from (
    select
    SUBSTRING(introduce,charindex('毕业于',introduce),charindex('大学',introduce)-charindex('毕业于',introduce))+'大学' as 学校
     from school) t1