IN statement in a stored procedure

  • Hi All,

    I have the following stored procedure:

    CREATE PROCEDURE dbo.ScoreHistory

    @StartDate int,

    @EndDate int,

    @membercode nvarchar(1),

    @Source nvarchar(2)

    AS

    SELECT DISTINCT(S.Score) AS Score, COUNT(U.ScoreID) AS Count

    FROM UPSELL U

    INNER JOIN ScoreMap S

    ON S.ScoreID = U.ScoreID

    WHERE SEARCHDATE BETWEEN @StartDate AND @EndDate

    AND membercode = @membercode

    AND PubCode = @Source

    GROUP BY S.Score

    What I need to be able to do is change the above to use the IN() statement on the variables @membercode and @Source. Any help will be appreciated.

    EO

  • ...

    AND membercode IN (@membercode)

    AND PubCode IN (@Source)

    ...

    John

  • eobiki10 (10/4/2013)


    What I need to be able to do is change the above to use the IN() statement on the variables @membercode and @Source. Any help will be appreciated.

    EO

    Why would you need that? your variables ar nvarchar(1) and nvarchar(2).

    The equal sign would be the same as an IN with a single value.

    Maybe you're giving us incorrect information and that way you might get incorrect solutions.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply