Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: SQL Server
Expertise: Beginner
Jul 8, 1999



Application Security Testing: An Integral Part of DevOps

Passing Text Fields

I need to pass large fields of text. Problem is, some of the text has single quotes in it ( ' ). How do I pass these text fields to SQL without getting an error?

For example:

sqlText = "EXEC sp_NewEntry '" &  thisText & "', '" & thatText & "', '" & moreText & "', '"
I need to wrap all of the text in single quotes to SQL, but if any of the text contains single quotes, it burps an error. What's the syntax to pass the text correctly?

I thought I saw a solution for this while I was in training, where they used square brackets and "`" as a delimiter, which was a new one on me. I'm not certain, but I think the thing to do is to use double single quotes ('') to mark the included quote mark.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date