Skip to main content
Participant
July 24, 2006
Question

Wacko MSSQL Error

  • July 24, 2006
  • 2 replies
  • 312 views
I am having problems inserting to a mssql database with single quotes around my data, does anyone know a way around this? The inserts work fine with out the single quotes. I am trying to wrap the form input to have the correct syntax that mssql requires, for instance:

<CFSET Head = ", ' ">
<CFSET Foot = "''">
<CFIF form.Project_Num neq "">
<CFSET Project_Num = Head&form.Project_Num&Foot>
<CFSET Project_NumCol = ", Project_Num">
<CFELSE>
<CFSET Project_Num = "">
<CFSET Project_NumCol = "">
</CFIF>

I am trying to make the code omit columns that dont have data entered, but the wrapping seems to not be working. Every time it tries to execute it errors to: Incorrect syntax near '2'.
This topic has been closed for replies.

2 replies

sakkakuAuthor
Participant
July 24, 2006
aye will try that, forgot about using that earlier.

Thx, that worked great.

feel sorta stuipid that i forgot about the single quote issue :(
Participating Frequently
July 24, 2006
Lookup the PreserveSingleQuotes() function, as this is probably what you will need to use within your CFQUERY.

Phil