Passing "%" wild card to stored procedure

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default 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 syntax near '%'.

    message. I get the same message from the query analyzer, if I dont use the
    single quotes. I cannot encase the % sign in single quotes or even double
    quotes in the asp page. Is there a way around this?

    Thanks for your help,
    John


    john Smith Guest

  2. Similar Questions and Discussions

    1. passing values to stored procedure
      Hello Can some please let me know how can I pass value to the following stored procedure from coldfusion template. It is written in different...
    2. Passing null into a stored procedure
      I have a survey form with both checkboxes and radio buttons... when storing the form, there are occassions that I need to store a NULL in the DB and...
    3. 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. ...
    4. 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...
    5. Passing arrays to a stored procedure
      http://www.aspfaq.com/2248 http://www.algonet.se/~sommar/arrays-in-sql.html http://www.algonet.se/~sommar/dynamic_sql.html "Doug Eller"...
  3. #2

    Default Re: Passing "%" wild card to stored procedure

    sSQL = "select whatever from whereever where something like '%something%'"

    What is your code/query/result of Response.Write YourQuery?

    Ray at work

    "john Smith" <smith@fakedomain.com> wrote in message
    news:%23F%23DYygAEHA.2308@tk2msftngp13.phx.gbl...
    > 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 syntax near '%'.
    >
    > message. I get the same message from the query analyzer, if I dont use
    the
    > single quotes. I cannot encase the % sign in single quotes or even double
    > quotes in the asp page. Is there a way around this?
    >
    > Thanks for your help,
    > John
    >
    >

    Ray at Guest

  4. #3

    Default Re: Passing "%" wild card to stored procedure

    "john Smith" <smith@fakedomain.com> wrote in message
    news:#F#DYygAEHA.2308@tk2msftngp13.phx.gbl...
    > 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 syntax near '%'.
    >
    > message. I get the same message from the query analyzer, if I dont use
    the
    > single quotes. I cannot encase the % sign in single quotes or even double
    > quotes in the asp page. Is there a way around this?
    >
    > Thanks for your help,
    > John

    Perhaps you could use Chr(37).


    McKirahan Guest

  5. #4

    Default Re: Passing "%" wild card to stored procedure

    My SP is:


    create proc AdvEmailReport
    @custno varchar(6),
    @indexno varchar (5),
    @issueno varchar (5)
    as
    select pubname +' ' + p.issue as pubname, a.custno, custname, i.issueno,
    indexno, count(*) as RespThisIssue,
    (select count(*) from index_readers i join readers_all r on i.readerno =
    r.readerno
    where reportdate = (select max(reportdate) from readers_all) and
    i.custno like @custno and i.issueno like @issueno
    and i.indexno like @indexno)
    as [TotalRespThisPeriod]

    It works fine when I query like so in the query analyser:

    exec AdvEmailReport 'cazgov', '%', 1025

    John

    "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
    message news:eNFkh2gAEHA.640@TK2MSFTNGP09.phx.gbl...
    > sSQL = "select whatever from whereever where something like '%something%'"
    >
    > What is your code/query/result of Response.Write YourQuery?
    >
    > Ray at work
    >
    > "john Smith" <smith@fakedomain.com> wrote in message
    > news:%23F%23DYygAEHA.2308@tk2msftngp13.phx.gbl...
    > > 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 syntax near '%'.
    > >
    > > message. I get the same message from the query analyzer, if I dont use
    > the
    > > single quotes. I cannot encase the % sign in single quotes or even
    double
    > > quotes in the asp page. Is there a way around this?
    > >
    > > Thanks for your help,
    > > John
    > >
    > >
    >
    >

    john Smith Guest

  6. #5

    Default Re: Passing "%" wild card to stored procedure

    john Smith wrote:
    > My SP is:
    >
    >
    > create proc AdvEmailReport
    > @custno varchar(6),
    > @indexno varchar (5),
    > @issueno varchar (5)
    >
    > It works fine when I query like so in the query analyser:
    >
    > exec AdvEmailReport 'cazgov', '%', 1025
    >
    Well, you did not show us the line of code causing your problem, but here is
    how I would run this stored procedure:

    'create and open your connection, cn, then
    set rs=createobject("adodb.recordset")
    cn.AdvEmailReport 'cazgov', '%', 1025, rs

    HTH,
    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] 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