更新时间:2022-01-05 10:05:34
SQL还具有 SUBSTRING [ ^ ]这样:
SQL also has SUBSTRING[^] so:
SELECT 'ABC' + SUBSTRING(myColumn, 3, LEN(MyColumn)) FROM MyTable
将删除前两个字符并在ABC上添加大头钉
[edit]缺少右括号[/edit]
Will remove the first two characters and tack on ABC
[edit]Missed a close bracket[/edit]
尝试以下脚本
Try the below script
declare @str varchar(1000),
@word varchar(100),
@newword varchar(100)
select @str = 'He is a positive influence on other students',
@word = 'He',
@newword = 'ABC'
select @str Old, stuff(@str, charindex(@word, @str), len(@word), @newword) new