Hi all,I am working on a Sproc that is being passed a list (comma seperated) variable, from an HTML select box. For example the list could contain :10,20,30I do have a function from that I use to split the list as follows :Create FUNCTION dbo.Split( @RowData nvarchar(2000), @SplitOn nvarchar(5)) RETURNS @RtnValue table ( Id int identity(1,1), Data nvarchar(100)) AS BEGIN Declare @Cnt int Set @Cnt = 1 While (Charindex(@SplitOn,@RowData)>0) Begin Insert Into @RtnValue (data) Select Data = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1))) Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData)) Set @Cnt = @Cnt + 1 End Insert Into @RtnValue (data) Select Data = ltrim(rtrim(@RowData)) ReturnEND
I have used it before successfully. But cannot get it to work in where clause.What I would like to do is something like this :WHERE [DATA] FROM DBO.SPLIT(@Category, ',')) = dbo.SpecialCategory.Category
Not working for me obviously. Question is should I be able to make this work or is there a better tool that I am not aware of in advance?Thanks in advance,Chris