April 12, 2019 at 6:35 pm
In a sql server 2012 database. I want to replace part of a value in the column called 'text' that is referring to one url link and replace the value with a new url link. This change needs to happen since the url (link) has changed in production recently.
The value that needs to be replaced is in the column listed below called 'stringtorepalce' with the new url link of 'https://dd1.org/app/letter.aspx'.
**Note the 'stringtoreplace' column had to be determined since the link in production has changed several times in the past 10 years.
SELECT text,
,PATINDEX('%https://%',text) as startlocation
,PATINDEX('%/letter.aspx%',text) as endlocation
,substring(text,PATINDEX('%https://%',text),PATINDEX('%/letter.aspx%',text) - PATINDEX('%https://%',text)) as stringtoreplace
FROM [dd1].[dbo].[Contact]
where text like '%spr.org%'
and text like '%/letter.aspx%'
and datetimestamp >= '2018-08-01 00:00:00.00'
order by datetimestamp desc
Basically the column called 'text' needs to be updated. Thus can you show me the sql on how to 'replace part of a value in the column called 'text' that is referring to one url link and replace the value with a new url link?
April 12, 2019 at 7:14 pm
Not sure if I got it correctly.... If you know sequence of characters you replacing use REPLACE() function. If you need to replace at certain positions, use STUFF() function.
--Vadim R.
April 12, 2019 at 7:48 pm
Can you post some sample data and the results you expect please? Make sure you're posting the data as formatted text (like you should be when pasting code). You can paste formatted text by click the Insert/edit code sample button and pasting the text there.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
April 15, 2019 at 3:06 pm
solved the problem
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply