How to create a querystring in procedure to insert string with single and double quote

searchsanjaysharma used Ask the Experts™
I want to pass a string in procedure containing single quote and/or double quote
My data entered in textbox is "I as 'as'  and as "India"

1/ How to pass this as parameter
2/ How to create querystring inside procedure

declare @qs nvarchar(max)
set qs=?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
lcohanDatabase Analyst

declare @qs nvarchar(max)
set @qs='"I as ''as''  and as "India"';
print @qs;

Open in new window

single quotes in a string must be put as two single quotes to show a(1) single quote and double quote is ok as is.


No this i also know but this is of no use.
Topic Advisor, Page Editor
Distinguished Expert 2018
Now, your string  "I as 'as'  and as "India" doenst make sense (to me) but you say above you already know that part....

But if you dont mind, please explain what that string represents to you, or, what you are wanting as a result.

If it is intended for use within a query, you would need to use Dynamic SQL if you want the procedure to effectively use the content of your parameter to use within a subsequent select query.

Or... You may also want to set quoted identifiers. When set to ON, anything in double quotes is an identifier (Table Name, Proc Name, Column Name….etc). See

Or, are you wanting to know how to call the Stored Procedure. Are you using a pass-through query, or ADO ?

Or, are you wanting something else ?

Please explain....

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial