Home > Net >  How to update a table column data, containing ( ' ) symble in data
How to update a table column data, containing ( ' ) symble in data

Time:01-24

I am getting error in microsoft sql server because the data I want to update is contains (') symbol in the data.

update Employee_table
set
brokername='Angie's Broker',
where ID=7788;

Please someome resolve the problem.

CodePudding user response:

   UPDATE Employee_table SET brokername = 'Angie''s Broker' WHERE id = 7788;

To update a table column that contains the single quote symbol ('), you can use the escape sequence ('') to represent the single quote in the data.

CodePudding user response:

For single quotes used inside a string literal, you put another single quote before it. This is called "escaping" the single quote, and different sorts of escaping are quite usual in programming:

update Employee_table
set
brokername='Angie''s Broker',
where ID=7788;

CodePudding user response:

Another way to escape the single quote is to use the unicode char like below :

update Employee_table
set brokername='Angie'   CHAR(39)   's Broker',
where ID=7788;
  • Related