How to Split Comma Separated Columns into separate rows ?

I have values in two columns separated by commas, like showm below


I need the Output Like

How to do this in SQL server ? Thank You in advance.

Thank You,

Aravindan

September 14th, 2015 6:01pm

Check out my article on splitters.

DECLARE @table TABLE (A NVARCHAR(20), B NVARCHAR(20))
INSERT INTO @table (A, B) VALUES
('1,2','a,b'),('3,4','x,y,z')

SELECT a.value AS columnA, b.value AS columnB
  FROM @table 
    CROSS APPLY dbo.splitter(A,',') a
	CROSS APPLY dbo.splitter(B,',') b

Free Windows Admin Tool Kit Click here and download it now
September 14th, 2015 6:05pm

I have values in two columns separated by commas, like showm below


I need the Output Like

How to do this in SQL server ? Thank You in advance.

Thank You,

Aravindan

September 14th, 2015 6:14pm