SQL服务器:如何删除所有记录中特定列的数据

SQL Server : how to delete particular column's data in all records

我有一个table这样的

Id  | Action
----+---------------------------------
 1  | GetUser
 2  | Restriction/GetRestrictedUsers

我想删除所有记录中的所有表达式,包括 '/' 斜线符号

比如Restriction/GetRestrictedUsers应该是这样GetRestrictedUsers

有什么帮助吗?

嗯。 . .试试这个(备份 table 之后):

update t
    set action = substring(action, charindex('/', action) + 1, len(action))
    where action like '%/%';
update table_name
set Action = SUBSTRING(Action, Charindex('/', action) + 1,len(action))
where action like '%/%';

作为替代方案,PARSENAME 函数 (2012+) 可能会被滥用。

update [YourTable]
set Action = PARSENAME(REPLACE(Action,'/','.'), 1)
where action like '%/%[^/]';