MY Table like this:
id Tag platform
1 #class1,#class2 CS
2 #class1 PS
3 #class2 CS
if i pass “‘#class1′” as parameter to SP getting only one record that is 2nd record.But need to 1st and 2nd records because #class1 contains in both 1,2 rows.Please tell me how to write this.I am using IN statement as of now.By using getting only record.
MY SP:
ALTER PROCEDURE [dbo].[usp_Get]-- 1,"'#class1,#class2'"
@Appid INT,
@TagList NVARCHAR (MAX)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT @TagList = '%' + RTRIM(LTRIM(@TagList)) + '%';
declare @tags varchar(MAX)
set @tags = @TagList
create table #t (tag varchar(MAX))
set @tags = 'insert #t select ' + replace(@tags, ',', ' union select ')
exec(@tags)
Select
id FROM dbo.List WHERE ((appid=@Appid)) AND ((Tags LIKE(select tag from #t)
END
How to modify please tell me…
Thanks in advance..
One solution would be to use LIKE operator in your stored procedure: