2

I am attempting to replace specific values in one column with a new value but it does not work (no errors, no replacement of values, nothing happen).

UPDATE Components
SET Unit='kg'
WHERE Unit='КГ'

How can I replace all values "КГ" with "kg" in column Unit?

3
  • do you get any error, or the SQL statement is executed successfully? Commented Jul 7, 2014 at 4:28
  • be more clear. We don't even know if your problem is an error of if you simply don't know how to do. If this is the case, please even show some effort. Otherwise show us the error you are facing Commented Jul 7, 2014 at 4:32
  • Define does not work - do you get an error? If so: what error?? Does it not actually update the table? Or is something else happening?? WHAT is happening?? Commented Jul 7, 2014 at 4:32

2 Answers 2

2

I thing that your Unit column is NVarChar() data type. Try following query:

UPDATE Components
SET Unit=N'kg'
WHERE Unit=N'КГ'

Another reason: If you have instead of update trigger on Components table and not update this column on it, your update not affected and no raise error too.

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

Comments

1

I suggest to use Quotename to resolve this, it is used for this type of string.

UPDATE Components
SET Unit=QUOTENAME('kg')
WHERE Unit=QUOTENAME('КГ')

It is simple and direct query which you run, then its ok. Other wise as @Mehdi said, I also fever that statement.

http://www.c-sharpcorner.com/Blogs/7515/quotename-function-in-sql-server.aspx

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.