SQL Stored Procedure Problem "Single Quotes"

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default SQL Stored Procedure Problem "Single Quotes"

    Quotes is something we all should be aware of when passing values to a Stored
    Procedure. However, this specific scenario I am really stuck on.


    SQL Stored Procedure:
    select *
    from tbl_table
    where forum_id IN ('first value,'second value')


    I'm trying to pass "First Value & Second Value" using a variable. The "QUOTES"
    gives problems when passing it to the procedure. I tried using other datatypes,
    but no luck. Any thoughts?

    tranzformerz Guest

  2. Similar Questions and Discussions

    1. Passing "%" wild card to stored procedure
      Hi everyone, This may be a simple question: When I pass "%" (without the quotes) in an asp page to a stored procedure, I get the Incorrect...
    2. Urgent: help needed : "Problem with double quotes"
      Hi, I want to call a PERL program from MS-DOS batch file. Following is just an example, the string may inturn have double quote or single quote....
    3. lock probs, implicit "update statistics for procedure .." ?
      Whe recently sometimes get lock problems at one of our customers. We found out, that the system tables sysprocplan and sysdistrib where locked by a...
    4. Trying to get smart quotes or "curly" quotes
      I've searched forums and help to no avail. How do I ensure that the quote marks I get displayed are smart quotes, in other words the curly kind...
    5. Can "Computed Column" be a stored procedure in SQL Server 2000?
      I am looking forward suggestions and solutions. I have a table and would like to add a "computed column" for reporting performance reason. The...
  3. #2

    Default Re: SQL Stored Procedure Problem "Single Quotes"

    You just need to wrap the entire variable (including your single quotes) in the
    PreserveSingleQuotes function. Basically, you need to double up your quotes
    when apssing so they will be escaped. This function does it for you.

    TA-Selene Guest

  4. #3

    Default Re: SQL Stored Procedure Problem "Single Quotes"

    Another way of looking at the Select Statement is:

    SQL Stored Procedure:
    declare @var int
    set @var = '1','2'
    select *
    from tbl_table
    where forum_id IN (@var)

    Just by looking at it, when setting @var to '1','2' you will get an error. I
    hope this helps in getting a better perspective on this.

    Thanks again....

    tranzformerz Guest

  5. #4

    Default Re: SQL Stored Procedure Problem "Single Quotes"

    TA-Selene thanks! I will give this a try and will post back my findings.
    tranzformerz Guest

  6. #5

    Default Re: SQL Stored Procedure Problem "Single Quotes"

    PreserveSingleQuotes did not solve the problem, however good function to
    consider when dealing with quotes. The problem was that this specific problem
    didn't work when using a STOREDPROCEDURE. I just did a straight CFQUERY rather
    than CFSTOREDPROC. There maybe other ways of approaching this, but this one
    worked. Thanks TA-Selene for the effort. I greatly appreciate the promptly
    response.

    tranzformerz Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139