devxlogo

Passing Text Fields

Passing Text Fields

Question:
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?

Answer:
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.

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist