Hi Experts,
Could you please help me in a pivot query? My table structure is given below:
CREATE TABLE [dbo].[SS_TestTable1]( [ID] [int] NOT NULL, [Name] [nvarchar](100) NULL, [EmailID1] [nvarchar](50) NULL, [EmailID2] [nvarchar](50) NULL, [EmailID3] [nvarchar](50) NULL, [EmailID4] [nvarchar](50) NULL)
INSERT [dbo].[SS_TestTable1] ([ID], [Name], [EmailID1], [EmailID2], [EmailID3], [EmailID4]) VALUES (100, N'Mark', N'abc@gmail.com', N'abc@yahoo.com', N'abc@hotmail.com', N'abc@rediffmail.com') INSERT [dbo].[SS_TestTable1] ([ID], [Name], [EmailID1], [EmailID2], [EmailID3], [EmailID4]) VALUES (200, N'Tom', N'xyz@gmail.com', N'sss@yahoo.com', N'ggg@hotmail.com', N'ooo@rediffmail.com')
Now I need the data in this format:
ID Name Email Values 100 Mark EmailID1 abc@gmail.com 100 Mark EmailID2 abc@yahoo.com 100 Mark EmailID3 abc@hotmail.com 100 Mark EmailID4 abc@rediffmail.com 200 Tom EmailID1 xyz@gmail.com 200 Tom EmailID2 sss@yahoo.com 200 Tom EmailID3 ggg@hotmail.com 200 Tom EmailID4 ooo@rediffmail.com
Could you help me with the query?
Thanks in advance