In TSQL (SQL SERVER 2008) how would I pass a -comma delimited - list of string values- eg. 'gold,silver,copper' to a User-defined function that specifies a varchar parameter.
I realize that if I define a varchar parameter in my UDF say @commodityList that takes the the list 'gold,silver,copper', I'm unable to use the IN operator. ie
SELECT * FROM Prodn where commodity in (@commodList).
I've read some articles on taking the Table-Valued Paremeter approach however I reckon going down that path would mean splitting my string into chunks - in order to Insert into a Table-valued Parameter e.g:
DECLARE @mylist commodity_list_tbltype
INSERT @mylist VALUES('gold'),('silver'),('copper')
I'm wondering if there is a direct approach of setting the string argument as it is, and using the SQL IN operator in a UDF.
Cheers.