In my SQL database, I have a SQL table where there is a column that stored the URL of some images that I am displaying on my website. The URL field is something like http://some_domain/some_thing
I need to replace all of them with something like https://some_domain/some_thing
I can write a C# script to do the same and write the required regex in C#. Does anyone know how to do this kind of replacement in SQL Server.
1条答案
按热度按时间lx0bsm1f1#
You need to search for all entries that have an
http://
prefix and then replace it, eg:The
WHERE
clause ensures that only entries withhttp://
are processed and allows the query to take advantage of possible indexes on the image field.LIKE 'abc%' is essentially a range search that matches values between
abcand the next entry after the prefix, ie
abd`