the following query throwing error. plz help me & tell me what is the error.
this query returing following result:
string sqlcmd = "UPDATE branch SET brac_subj = " + query_data + " WHERE (braid = "+dd_branch+")";
UPDATE branch SET brac_subj = "'11' , '12' , '13' , '14' , '15' , '16' , '17' , '18' , '19' , '20' , '21'" WHERE (braid = 1)
how can i store the string in following format:
'11' , '12' , '13' , '14' , '15' , '16' , '17' , '18' , '19' , '20' , '21'
The problem you are running into Enigma is called Escaping. Since single quotes is a restricted character, and defines the start of a string in SQL, you can’t use it as-is inside that same string.
In addition to that, it looks like you are under the impression that SQL Server uses doubles quotes to define a string, and it does not.
This syntax will not work:
This syntax will work:
The trick is using your programming code to add those extra apostrophe’s around the values, thus the answers that everyone else is suggesting.
Also, an easy way to test this syntax is a short select statement:
vs