4

I have a table in the database where it contains some of the user name. When I copy the database files from one machine to other machine, I need to manually update this table. The table contains the username in the following format

<domain name>\Username

the domain mostly the local machine name (the user exists within the system). What I am trying to write a simple SQL Query to find a pattern (machine name) and replace with a new one.

I am not so proficient with SQL queries. Can you share a sample snippet? I am using SQL Server 2008

1
  • 1
    did you miss something in the format (in the question) ? What is domain in this context? Commented Nov 9, 2011 at 11:26

2 Answers 2

9
UPDATE table_that_contains_users
SET field_user = replace( field_user, 'OLDDOMAIN\', 'NEWDOMAIN\')

is that?

Sign up to request clarification or add additional context in comments.

Comments

0

Try this statement:

UPDATE your_table SET machine_name = REPLACE(machine_name, machine_name, 'Your New Value')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.