SQL % Sign issues

Posted on 2011-04-26
Last Modified: 2012-05-11
I have a table where an organization is identified by a client number.  For some of our searches, we must combine these client numbers within an IN statement to get combined results (see below):

Single client data set:
select *
from table
where client number=12345

Client chain data set:
select *
from table
where client number in (12345,22345,32345)

However, within the database, we have previously used the % sign as an identifier for ALL locations within a chain.

Where client number in (12345,22345,32345)

This works just fine


Where client number in (%) does not work.  The correct syntax is WHERE client number in ('%')

also WHERE client number in ('12345,22345,32345') does not work - the apostrophes throw it off.

I would rather not hard code each of the % to a list as we add and remove locations within the chain from time to time.

Any suggestions on how to work around this?
Question by:simplyfemales
    LVL 6

    Accepted Solution

    WHERE client number in ('12345','22345','32345')

    Author Closing Comment

    DOH!  I should have seen that.  If I could give extra credit, I would.

    LVL 6

    Expert Comment

    Any time, its an easy mistake

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    SQL Server - Performance Very Sluggish 14 58
    How to script out data export 36 55
    best way to upgrade 3 29
    Custom auto number 6 27
    Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
    The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now