如上图 如何批量替换http://www.sss.cn/Port/ftp/myapp/ 这个地址后面的ip地址 全部替换为
http://168.174.5.222:1234/zip/xx
最终结果都替换为:http://168.174.5.222:1234/zip/xx
可变参数不知道怎么处理 求高手!
------解决方案--------------------
是用replace,有什么问题?
------解决方案--------------------
就是用replace。。。。。BinGo..
------解决方案--------------------
?
UPDATE TEST
SET Contents= 'http://168.174.5.222:1234/zip/xx'
WHERE Contents like 'http://www.sss.cn/Port/ftp/myapp/%.%.%.%'
------解决方案--------------------
楼主表达不清楚,请重新表达你的意思。结果应该是什么,多给几笔测试数据和想要的结果
------解决方案--------------------
--楼主的表述不清楚,我估计就这两种可能:
--1.全部更新
--> 测试数据:@T
declare @T table([id] int,[contents] varchar(46))
insert @T
select 1,'http://www.sss.cn/Port/ftp/myapp/192.168.0.1' union all
select 2,'http://www.sss.cn/Port/ftp/myapp/192.168.0.2' union all
select 3,'http://www.sss.cn/Port/ftp/myapp/201.168.0.3' union all
select 4,'http://www.sss.cn/Port/ftp/myapp/235.168.0.4' union all
select 5,'http://www.sss.cn/Port/ftp/myapp/192.168.0.43' union all
select 6,'http://www.sss.cn/Port/ftp/myapp/192.168.0.3' union all
select 7,'http://www.sss.cn/Port/ftp/myapp/192.168.0.1' union all
select 8,'http://www.sss.cn/Port/ftp/myapp/192.168.0.455'
update @T set contents='http://168.174.5.222:1234/zip/xx'
select * from @T
/*
id contents
----------- ----------------------------------------------
1 http://168.174.5.222:1234/zip/xx
2 http://168.174.5.222:1234/zip/xx
3 http://168.174.5.222:1234/zip/xx
4 http://168.174.5.222:1234/zip/xx
5 http://168.174.5.222:1234/zip/xx
6 http://168.174.5.222:1234/zip/xx
7 http://168.174.5.222:1234/zip/xx
8 http://168.174.5.222:1234/zip/xx
*/
--2.更新除地址以外的内容
declare @T1 table([id] int,[contents] varchar(46))
insert @T1
select 1,'http://www.sss.cn/Port/ftp/myapp/192.168.0.1' union all
select 2,'http://www.sss.cn/Port/ftp/myapp/192.168.0.2' union all
select 3,'http://www.sss.cn/Port/ftp/myapp/201.168.0.3' union all
select 4,'http://www.sss.cn/Port/ftp/myapp/235.168.0.4' union all
select 5,'http://www.sss.cn/Port/ftp/myapp/192.168.0.43' union all
select 6,'http://www.sss.cn/Port/ftp/myapp/192.168.0.3' union all
select 7,'http://www.sss.cn/Port/ftp/myapp/192.168.0.1' union all
select 8,'http://www.sss.cn/Port/ftp/myapp/192.168.0.455'
update @T1
set contents='http://'+right([contents],charindex('/',REVERSE([contents]))-1)+':1234/zip/xx'
select * from @T1
/*
id contents
----------- ----------------------------------------------
1 http://192.168.0.1:1234/zip/xx
2 http://192.168.0.2:1234/zip/xx
3 http://201.168.0.3:1234/zip/xx
4 http://235.168.0.4:1234/zip/xx
5 http://192.168.0.43:1234/zip/xx
6 http://192.168.0.3:1234/zip/xx
7 http://192.168.0.1:1234/zip/xx
8 http://192.168.0.455:1234/zip/xx
*/
------解决方案--------------------
是这样吗:
--> 测试数据:@T
declare @T table([id] int,[contents] varchar(100))
insert @T
select 1,'http://www.sss.cn/Port/ftp/myapp/192.168.0.1' union all
select 2,'http://www.sss.cn/Port/ftp/myapp/192.168.0.2' union all
select 3,'http://www.sss.cn/Port/ftp/myapp/201.168.0.3' union all
select 4,'http://www.sss.cn/Port/ftp/myapp/235.168.0.4' union all
select 5,'http://www.sss.cn/Port/ftp/myapp/192.168.0.43' union all
select 6,'http://www.sss.cn/Port/ftp/myapp/192.168.0.3' union all
select 7,'http://www.sss.cn/Port/ftp/myapp/192.168.0.1' union all
select 8,'http://www.sss.cn/Port/ftp/myapp/192.168.0.455'