I recently came across a Database Migration task that required me to apply some corrective measures to the database after it was migrated to another server.
I had a users table in which the data was tied with the Windows logins on the old Server.
So the Username field in the users table was of the format “OLDSERVER\xxxxx”.
After migrating the database I had to replace the “OLDSERVER” to “NEWSERVER” so the users would look like “NEWSERVER\xxxxx”
I used the REPLACE function in SQL Server to get the job done.
Below is the query that allowed me to achieve that :
UPDATE [Users] SET [Username] = REPLACE([Username],'OldServer\','NewServer\') WHERE [Username] like 'OldServer\%';