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

I want to pass a string in procedure containing single quote and/or double quote
Ex:
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=?
searchsanjaysharmaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lcohanDatabase AnalystCommented:
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.
0
searchsanjaysharmaAuthor Commented:
No this i also know but this is of no use.
0
Mark WillsTopic AdvisorCommented:
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 https://docs.microsoft.com/en-us/sql/t-sql/statements/set-quoted-identifier-transact-sql?view=sql-server-2017

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....
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.