To display a comma separated varchar into table with columns,
Ex: input:@csvstring varchar(100) = 'prod1,prod2,prod3,prod4'
output:
products
prod1
prod2
prod3
prod4
Script to acheive this in sql:
DECLARE @param NVARCHAR(MAX)
SET @param = 'prod1,prod2,prod3,prod4'
DECLARE @paramToCSV XML
SET @paramToCSV = CAST ('<M>' + REPLACE(@param, ',', '</M><M>') + '</M>' AS XML)
SELECT prod.query('./text()') AS products
FROM @paramToCSV.nodes('/M') AS Bike(prod);