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.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: