Wednesday, March 28, 2012

Passing multi-valued parameter to a Sp

Hello,

I am forced to use a Sp in teh first place as my query is too long for the text dataset. I have a parameter Time_Period which ia a multivalued one but it is not allowing me to use this in the SP. using RS 2005.

Any help appereciated.

Thanks

You can use multivalue input params from RS to a stored proc. The input param comes in like a single string like @.Input = 'Val1,Val2,Val3' and then you can split these with a table function which returns 'Val1',Val2','Val3' . Then, use an IN stmt in your where statement in the stored proc ie WHERE Val IN (SELECT Item FROM dbo.SplitParams ('''+ @.Input + ''', '',''))'. See this thread for more info.

No comments:

Post a Comment