Jos*_*lio 70
这是使用REPLACE函数完成的
要从SELECT查询中的"SomeTable"中的"SomeColumn"中去掉"somestring":
SELECT REPLACE([SomeColumn],'somestring','') AS [SomeColumn] FROM [SomeTable]
Run Code Online (Sandbox Code Playgroud)
更新表并从"SomeTable"中的"SomeColumn"中删除"somestring"
UPDATE [SomeTable] SET [SomeColumn] = REPLACE([SomeColumn], 'somestring', '')
Run Code Online (Sandbox Code Playgroud)
mar*_*c_s 14
在相关列上使用"REPLACE"字符串函数:
UPDATE (yourTable)
SET YourColumn = REPLACE(YourColumn, '*', '')
WHERE (your conditions)
Run Code Online (Sandbox Code Playgroud)
将"*"替换为要删除的字符,并指定WHERE子句以匹配要应用更新的行.
当然,也可以使用REPLACE函数 - 正如其他回答者所示 - 在SELECT语句中 - 从您的问题来看,我假设您正在尝试更新表.
渣
看看以下函数 - REPLACE():
select replace(DataColumn, StringToReplace, NewStringValue)
//example to replace the s in test with the number 1
select replace('test', 's', '1')
//yields te1t
Run Code Online (Sandbox Code Playgroud)
http://msdn.microsoft.com/en-us/library/ms186862.aspx
编辑
如果你想删除一个字符串,简单地使用带有空字符串的replace函数作为第三个参数,如:
select replace(DataColumn, 'StringToRemove', '')
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
106502 次 |
最近记录: |