? Must declare scalar variable ? on a multi slect

  • Hi

    I'm not sure what I am doing wrong I have a multi select parameter which work if I only choose one value

    but I get Must declare the scalar variable "@None" when I choose more than one

    here is a snipet of my code

    ALTER PROCEDURE [dbo].[CASELOAD]

    @Program NVARCHAR (MAX)

    ,@None VARCHAR (8000)

    As

    Select....

    where ...

    --AND

    -- Table.Name

    -- IN (@None)

    Thanks

    Joe

  • jbalbo (5/8/2015)


    Hi

    I'm not sure what I am doing wrong I have a multi select parameter which work if I only choose one value

    but I get Must declare the scalar variable "@None" when I choose more than one

    here is a snipet of my code

    ALTER PROCEDURE [dbo].[CASELOAD]

    @Program NVARCHAR #MAX#

    ,@None VARCHAR #8000#

    As

    Select....

    where ...

    --AND

    -- Table.Name

    -- IN #@None#

    Thanks

    Joe

    I am assuming you are passing in a comma delimited string in the @NONE parameter of your stored procedure. You need to do something like this:

    ...

    where ...

    --AND

    -- Table.Name IN (select Item from dbo.DelimitedSplit8K(@None,','))

    You can find the dbo.DelimitedSplit8K function under resources with this article: http://www.sqlservercentral.com/articles/Tally+Table/72993/.

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

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