SQL Server从第二次出现到结束删除所有内容
我的SQL Server表中有一列包含文本,假设一行包含以下文本:SQL Server从第二次出现到结束删除所有内容,sql,sql-server,match,Sql,Sql Server,Match,我的SQL Server表中有一列包含文本,假设一行包含以下文本: "this is a test that was made the year 2012 cause in the year 2013 we was down" 我需要的是检查一年是否发生过不止一次;如果是,文本应更新为: "this is a test that was made the year 2012 cause in the " 所以我需要在第二次出现之前保留所有内容,并删除从上次出现到结束的所有内容 有什么帮助吗?
"this is a test that was made the year 2012 cause in the year 2013 we was down"
我需要的是检查一年是否发生过不止一次;如果是,文本应更新为:
"this is a test that was made the year 2012 cause in the "
所以我需要在第二次出现之前保留所有内容,并删除从上次出现到结束的所有内容
有什么帮助吗?这很痛苦,但你可以做到:
select (case when col like '%year%year%'
then left(col,
charindex('year', col, charindex('year', col) + 4) - 1
)
else col
end) as first_year_only
有效年限是多少年。1973年有效吗?2199有效吗?当我插入要搜索的列名时,我得到的列名无效in@GeorgeNaffah . . . 也许你错过了一个需要插入的地方。