Monday, January 28, 2013

Sql Server Escape Character in INSERT/UPDATE

Sql Server Escape Character in INSERT/UPDATE


If u choose string limiter as single quote('), part of the string has single quotation user may get 

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

 so  insert one more single quote . to solve this.

Insert into Store(StoreName,City,Desc) values('jhon''s store',
                                                 'New York',
                                                'jhon''s store has all apparels'



Same thing for UPDATE statement



tags:Sql Server Escape Characters in Insert/Update,Escape Characters in SQL Server.


No comments:

Post a Comment