Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL替换为更改值_Sql_Sql Server_Replace - Fatal编程技术网

SQL替换为更改值

SQL替换为更改值,sql,sql-server,replace,Sql,Sql Server,Replace,我需要能够替换一个字段中的值,例如I.p-但是这个I.p会改变 我尝试使用CHARINDEX和子字符串 case when cr.DateOfCall between convert(varchar, getdate(), 112) and convert(varchar, getdate() +1, 112) then '\\10.10.111.5\Recordings\***\' + substring(***, charindex

我需要能够替换一个字段中的值,例如I.p-但是这个I.p会改变

我尝试使用CHARINDEX和子字符串

    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)
我将如何做,以便它将替换为文本

例如:

我有I.p[或[但我需要它说-“../EXAMPLE…”

请尝试:

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

您需要值
http://10.10.111.5/xyz/as.c
as
http://EXAMPLE/xyz/as.c
?问题不清楚。顺便问一下,为什么在这里将日期转换为varchar?