I have a configuration table where application url get stored. Application is on various server and everytime when we need to setup a new server, we need to update the values by selecting and running a while loop in sql. Scenerios is like
Table : Configuration
Id | key | DefaultUrl
1 | Key1 | www.xxx.com/something1
2 | key2 | www.xxx.com/something2
3 | key3 | www.xxx.com/something3
The only possible problem is when
www.xxx.com is somewhere in the middle of the url and it shouldn't be replaced. Use some forbidden in url character
' ' for example.
UPDATE [Configuration Values] SET DefaultUrl = replace(' '+DefaultUrl, ' www.xxx.com', 'www.yyy.com') WHERE DefaultUrl LIKE 'www.xxx.com%'