Below code works for \'Main Stream\' or \'Premium\' as parameter, however I am trying to make it work for both of them as you can see below, but it doesn\'t return any resul
You could try something like
--Split
DECLARE @textXML XML
DECLARE @data NVARCHAR(MAX),
@delimiter NVARCHAR(5)
SELECT @data = 'Main Stream , Premium',
@delimiter = ','
SELECT @textXML = CAST('' + REPLACE(@data, @delimiter, ' ') + ' ' AS XML)
SELECT T.split.value('.', 'nvarchar(max)') AS data
FROM @textXML.nodes('/d') T(split)
You could either store this in a temp table, or use it in the IN clause.
For @Hoy comment
You could look at nodes() Method (xml Data Type)
The nodes() method is useful when you want to shred an xml data type instance into relational data. It allows you to identify nodes that will be mapped into a new row.
Also, have a look at xml Data Type Methods
You could then use it as
select *
FROM sales
where myCategory IN (
SELECT T.split.value('.', 'nvarchar(max)')
FROM @textXML.nodes('/d') T(split)
)