我如何在字符串中搜索字符串?
例如:
“状态从“打开”更改为“关闭””
新列应返回“已关闭”
非常感谢。
答案 0 :(得分:0)
在字符串中搜索字符串可以使用:
CHARINDEX ( expressionToFind , expressionToSearch [ , start_location ] )
答案 1 :(得分:0)
您没有提供足够的上下文来正确回答您的问题,示例数据等,但是您可以从这里开始。
SELECT 'Closed' AS [NEW_STATUS], *
FROM [YourTable]
WHERE [STATUS] -- or whatever the name of the column is that contains the status change text
LIKE "%to 'Closed'%"
根据您的情况的替代解决方案:
SELECT
CASE WHEN [StatusText] LIKE "%to 'Closed%"
THEN 'Closed'
WHEN [StatusText] LIKE "%to 'Open%"
THEN 'Open'
END AS [CurrentStatus]
FROM [YourTable]