0

I am trying to write an SQL script where I can replace data in multiple columns, see below:

SQL Script:

UPDATE SohailsTest.dbo.OBJECT
SET VARIABLE = REPLACE(VARIABLE, 'C:\', 'E:\')
SET STATIC = REPLACE(STATIC, 'C:\', 'E:\');

I have tried the above, but it says:

Error Message:

Msg 102, Level 15, State 1, Line 3 Incorrect syntax near '='.

What am I doing wrong?

1
  • 3
    SET VARIABLE = REPLACE(VARIABLE, 'C:\', 'E:\'), STATIC = REPLACE(STATIC, 'C:\', 'E:\'); Commented Dec 7, 2015 at 15:25

2 Answers 2

5

You need to use only one SET:

UPDATE SohailsTest.dbo.OBJECT
SET [VARIABLE] = REPLACE([VARIABLE], 'C:\', 'E:\'),
    [STATIC] = REPLACE([STATIC], 'C:\', 'E:\');
Sign up to request clarification or add additional context in comments.

Comments

3

Try this:

UPDATE SohailsTest.dbo.OBJECT
SET VARIABLE = REPLACE(VARIABLE, 'C:\', 'E:\'), STATIC = REPLACE(STATIC, 'C:\', 'E:\');

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.