SQL替换为更改值

问题描述:

我需要能够替换字段中的值,例如I.P - 但这个I.P会改变。SQL替换为更改值

我曾尝试使用CHARINDEX和SUBSTRING

case when cr.DateOfCall between convert(varchar, getdate(), 112) and convert(varchar, getdate() +1, 112) then 
      '\\10.10.111.5\Recordings\***\' + 
      substring(***, charindex('\201', ***) + 1, 100) 

我会怎么做,所以它会与文本替换

例子:

我有IP [http://10.10.111.5...]或[ http://11.11.222.6...]但我需要这样说 - “... // EXAMPLE ...”

+0

您需要'http:// 10.10.111.5/xyz/as.c'作为'http:// EXAMPLE/xyz/as.c'? – TechDo

+0

问题不清楚。顺便说一句,你为什么在这里将日期转换为varchar? – Kaf

请尝试:

declare @tbl as table(Col nvarchar(max)) 
insert into @tbl values ('http://10.10.111.5/xyz/as.c') 
insert into @tbl values ('http://11.11.222.6/asdf/hhl/as.c') 

select Stuff(Col, charindex('//', Col, 0)+2, charindex('/', replace(Col, '//', ''), 0)-charindex('//', Col, 0), 'EXAMPLE') 
From @tbl