hi i have one doubt in sql server
how to combine two columns data into in to one columns and identification filed with values
CREATE TABLE [dbo].[empsal](
[eid] [int] NULL,
[salfrequence] varchar NULL,
[salary] [money] NULL
) ON [PRIMARY]
GO
INSERT [dbo].[empsal] ([eid], [salfrequence], [salary]) VALUES (1, N'monthly', 100.0000)
GO
INSERT [dbo].[empsal] ([eid], [salfrequence], [salary]) VALUES (2, N'quartely', 300.0000)
GO
INSERT [dbo].[empsal] ([eid], [salfrequence], [salary]) VALUES (3, N'years', 200000.0000)
GO
based on above data i want out put like below :
eid |salfrequence |typeofmode
1 |100.00 |payvalue
1 |monthly |paytype
2 |300.00 |payvalue
2 |quartely |paytype
3 |200000.00 |payvalue
3 |years |paytype
I tried like below :
select eid,salfrequence ,'paytype' typeofmode from empsal
union
select eid,cast(salary as varchar(50)) ,'payvalue'typeofmode from empsal
its give correctly values.i want get same data without using union and union all concept
can you please tell me how to write query to achive this task in sql servr .