single quote in query… | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

single quote in query…

Hi All, The problem i am facing looks similar to Pankaj but i am not getting appropriate solution to it. My prob goes like this I have a table Table 1 with field name as table 1 Name
sur’jit i need to update Name Sur’jit to Rama where name= sur’jit Update table1 set ‘Sur’jit’=’Rama’ where name =’sur’jit’ The query returns error. Please help how should I go fo this. Surjit
use 2 single quote instead.
update table1 set name = ‘Rama’ where name = ‘sur”jit’
KH
or update table1 set name = ‘Rama’ where name = ‘sur’+char(39)+’jit’
Madhivanan Failing to plan is Planning to fail
quote:Originally posted by Madhivanan or update table1 set name = ‘Rama’ where name = ‘sur’+char(39)+’jit’
Madhivanan Failing to plan is Planning to fail

Thanks a lot.Can you please let me know wht to do if there is double qupte("). Surjit
You can directly use double quote update table1 set name = ‘Rama’ where name = ‘sur"jit’
Madhivanan Failing to plan is Planning to fail
Also, its worth noting that if you use certain connectivity libraries (including ADO / ADO.NET), you should always bind your inputs to parameters, and pass them that way. This does all the quote translation for you… its a recommended practice anyway, constructing dynamic sql can easily be insecure and buggy
]]>