Hi all,

DECLARE @STA as char(50)
SET @STA = 'TT'
SELECT * FROM ABC_TBL where ABC_Filed in (@STA)

if i have multivalue in parameter @STA, like 'TT', 'DD', 'AA'
so how can i write my statement? i only need to pass one parameter with multilist, so do anybody know how to write the MS sql statement?
Example like
DECLARE @STA as char(50)
SET @STA = 'TT', 'DD'
SELECT * FROM ABC_TBL where ABC_Filed in (@STA)

Thank You.

Regards,
S3ng

How are you building the string before submitting it as the parameter value?

have a look at the sp_executesql (or is it sp_execute -- can't remember). with this method, you build your string in SQL, then execute it with the SP above. BOL should have more info and examples

you want to use dynamic sql

DECLARE @STA as char(50)
SET @STA = '''TT'', ''DD'''

exec ('SELECT * FROM ABC_TBL where ABC_Filed in ('+'@STA')')

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.