关于替换字符的问题
便如有个表
create table #s
(name char(30))
insert into
select '(限50)aaas'
insert into
select '(限5)aaa1'
insert into
select '(限100)aaa2'
怎样用一条语句把(限**)这部分数据替换掉
最后查询结果是
aaas
aaa1
aaa2
我只是举个例子。需要改的条数很多。可以设置变量,循环。
希望大侠们可以帮帮忙。
[解决办法]
select RIGHT(rtrim(name),len(name)-charindex(')',name))name from #s/*name------------------------------aaasaaa1aaa2(3 行受影响)*/
[解决办法]
create table #s (name char(30))insert into #sselect '(限50)aaas'insert into #sselect '(限5)aaa1'insert into #sselect '(限100)aaa2'goselect RIGHT(rtrim(name),len(name)-charindex(')',name))name from #s/*name------------------------------aaasaaa1aaa2(3 行受影响)*/
[解决办法]
create table #s (name char(30))insert into #s select '(限50)aaas'union allselect '(限5)aaa1'union allselect '(限100)aaa2'select STUFF(name,1,CHARINDEX(')',name),'') from #s drop table #s