Using wildcards in a WHERE statement

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

  1. #1

    Default Using wildcards in a WHERE statement

    I'm in the process of converting from Access to SQLServer and need help
    with using wild cards in a WHERE statement. When the following statement
    is executed, the error message
    'Invalid operator for data type. Operator equals boolean AND, type
    equals varchar.' is returned.

    SELECT DISTINCT
    udtZone, udtLocationKey, udtLocationName, udtLocationAddressLine1,
    udtLocationAddressLine2, udtLocationAddressCity,
    udtLocationAddressZipCode, udtLocationTelephoneGeneral, charComplex,
    varCharCategoryDescriptionLong, charAirportCode, vcharLocationType,
    bitShowAddressByDefaultInResults
    FROM view_SelectLocationsByAddressOrTelephone
    WHERE (udtLocationAddressLine1 LIKE '%' & 'boulevard' & '%')
    ORDER BY varCharCategoryDescriptionLong, udtLocationName;

    In the final implementation 'boulevard' will be replaced with a variable.

    David H


    David C. Holley Guest

  2. Similar Questions and Discussions

    1. help on SQL statement
      Hi, I have two tables: the first one has all details about persons, the second associate the id of each person to the id of his team leader...
    2. Wildcards
      Why isn't it possible to search with wildcards (like * and ?) in Acrobat 6? In Acrobat 5 it used to be possible. What is the alternative?
    3. File copy wildcards
      I have a directory with files named: ex0915 dx0915 gg0915
    4. Finding filenames using wildcards
      I have an interesting challenge. I have a client that is putting pictures into a single folder on the web server. The files are specific in that...
    5. Wildcards in rename()?
      Hi all! Do any of you know if wildcards are accepted when calling rename() function? Thanks/Alvaro
  3. #2

    Default Re: Using wildcards in a WHERE statement

    WHERE (udtLocationAddressLine1 LIKE '%boulevard%')


    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    [url]www.ielearning.com[/url]


    "David C. Holley" <DavidCHolley@netscape.net> wrote in message
    news:eG298pbaEHA.3508@TK2MSFTNGP09.phx.gbl...
    > I'm in the process of converting from Access to SQLServer and need help
    > with using wild cards in a WHERE statement. When the following statement
    > is executed, the error message
    > 'Invalid operator for data type. Operator equals boolean AND, type
    > equals varchar.' is returned.
    >
    > SELECT DISTINCT
    > udtZone, udtLocationKey, udtLocationName, udtLocationAddressLine1,
    > udtLocationAddressLine2, udtLocationAddressCity,
    > udtLocationAddressZipCode, udtLocationTelephoneGeneral, charComplex,
    > varCharCategoryDescriptionLong, charAirportCode, vcharLocationType,
    > bitShowAddressByDefaultInResults
    > FROM view_SelectLocationsByAddressOrTelephone
    > WHERE (udtLocationAddressLine1 LIKE '%' & 'boulevard' & '%')
    > ORDER BY varCharCategoryDescriptionLong, udtLocationName;
    >
    > In the final implementation 'boulevard' will be replaced with a variable.
    >
    > David H
    >
    >

    Mark Schupp Guest

  4. #3

    Default Re: Using wildcards in a WHERE statement

    & is not a string operator in T-SQL, it's a BITWISE operator! I think you
    meant '%'+'boulevard'+'%' or just '%boulevard%'

    --
    [url]http://www.aspfaq.com/[/url]
    (Reverse address to reply.)




    "David C. Holley" <DavidCHolley@netscape.net> wrote in message
    news:eG298pbaEHA.3508@TK2MSFTNGP09.phx.gbl...
    > I'm in the process of converting from Access to SQLServer and need help
    > with using wild cards in a WHERE statement. When the following statement
    > is executed, the error message
    > 'Invalid operator for data type. Operator equals boolean AND, type
    > equals varchar.' is returned.
    >
    > SELECT DISTINCT
    > udtZone, udtLocationKey, udtLocationName, udtLocationAddressLine1,
    > udtLocationAddressLine2, udtLocationAddressCity,
    > udtLocationAddressZipCode, udtLocationTelephoneGeneral, charComplex,
    > varCharCategoryDescriptionLong, charAirportCode, vcharLocationType,
    > bitShowAddressByDefaultInResults
    > FROM view_SelectLocationsByAddressOrTelephone
    > WHERE (udtLocationAddressLine1 LIKE '%' & 'boulevard' & '%')
    > ORDER BY varCharCategoryDescriptionLong, udtLocationName;
    >
    > In the final implementation 'boulevard' will be replaced with a variable.
    >
    > David H
    >
    >

    Aaron [SQL Server MVP] Guest

  5. #4

    Default Re: Using wildcards in a WHERE statement

    And completed its actually

    strSQLStatement = strSQLStatement & "(udtLocationAddressLine1 Like '%" &
    scrubCriteriaValue(session("rqs_searchCriteriaValu eAddress")) & "%') "

    THX
    David H

    [url]www.gatewayorlando.com[/url]

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    David Holley Guest

  6. #5

    Default Re: Using wildcards in a WHERE statement

    So, response.write strSQLStatement and show us what that yields. Tough for
    us to tell you anything, since we don't know what the rest of
    strSQLStatement is, we don't know what's in session("rqs_ridiculous_name")
    and we don't know what scrubCriteriaValue() does.

    --
    [url]http://www.aspfaq.com/[/url]
    (Reverse address to reply.)




    "David Holley" <davidcholley@netscape.net> wrote in message
    news:OQm0mRcaEHA.972@TK2MSFTNGP12.phx.gbl...
    > And completed its actually
    >
    > strSQLStatement = strSQLStatement & "(udtLocationAddressLine1 Like '%" &
    > scrubCriteriaValue(session("rqs_searchCriteriaValu eAddress")) & "%') "
    >
    > THX
    > David H

    Aaron [SQL Server MVP] Guest

  7. #6

    Default Re: Using wildcards in a WHERE statement

    SELECT DISTINCT udtZone, udtLocationKey, udtLocationName,
    udtLocationAddressLine1, udtLocationAddressLine2,
    udtLocationAddressCity, udtLocationAddressZipCode,
    udtLocationTelephoneGeneral, charComplex,
    varCharCategoryDescriptionLong, charAirportCode, vcharLocationType,
    bitShowAddressByDefaultInResults FROM
    view_SelectLocationsByAddressOrTelephone WHERE (udtLocationAddressLine1
    Like '%boulevard%') ORDER BY varCharCategoryDescriptionLong,
    udtLocationName;

    [url]www.gatewayorlando.com[/url]

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    David Holley Guest

  8. #7

    Default Re: Using wildcards in a WHERE statement

    David Holley wrote:
    > SELECT DISTINCT udtZone, udtLocationKey, udtLocationName,
    > udtLocationAddressLine1, udtLocationAddressLine2,
    > udtLocationAddressCity, udtLocationAddressZipCode,
    > udtLocationTelephoneGeneral, charComplex,
    > varCharCategoryDescriptionLong, charAirportCode, vcharLocationType,
    > bitShowAddressByDefaultInResults FROM
    > view_SelectLocationsByAddressOrTelephone WHERE
    > (udtLocationAddressLine1 Like '%boulevard%') ORDER BY
    > varCharCategoryDescriptionLong, udtLocationName;
    >
    Nothing sticks out to me. I suggest pasting this statement into Query
    Analyzer so you can debug it there. Start removing things until it runs
    without error. That shoule give you a clue.
    If you need further assistance, you will need to provide us with your table
    (in the form of a CREATE TABLE statement) and some sample data (in the form
    of INSERT ...VALUES statements) so we can reproduce the problem.

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  9. #8

    Default Re: Using wildcards in a WHERE statement

    Nothing sticks out as to why it doesn't work, because it works. I only
    posted the full SQL statement because it sounded as if someone wanted to
    see it in toto.

    David H

    [url]www.gatewayorlando.com[/url]

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    David Holley Guest

  10. #9

    Default Re: Using wildcards in a WHERE statement

    Hi David,

    I'm in the process of doing the same migration and got the same error. Did you discover why? Thanks!

    Chris

    ************************************************** ********************
    Sent via Fuzzy Software @ [url]http://www.fuzzysoftware.com/[/url]
    Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
    creejohnson@mindspring.com Guest

  11. #10

    Default Re: Using wildcards in a WHERE statement

    Yes, I did get the answer, but I don't remember it. Scroll up in the
    messages & replies and you should find the solution.

    David H
    (Bit tired at the moment)

    [url]www.gatewayorlando.com[/url]

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    David Holley 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