Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Help need in Avoiding Loop

$
0
0

Hi,

My table and data:

Create table Sample(Empid int primary key identity(1,1),EmpName varchar(50),Empsalary  money,EmpDesignation varchar(30));

insert into Sample values('Jhon',8000,'Manager'),
('Smith',6000,'Lead'),
('Samuel',4000,'AccountExecutive'),
('Simson',4000,'AccountSpecialist'),
('Eric',22000,'Director'),
('Jonathan',12000,'SeniorManager')

Expected Result

select  'EmpName','Jhon','Smith','Samuel','Simson','Eric','Jonathan' union all
select 'Salary','8000','6000','4000','4000','22000','12000' union all
select 'Designation','Manager','Lead','AccountExecutive','AccountSpecialist','Director','SeniorManager'

Is it possible to do without using loop? can anyone please give me some sample query to achieve. Also 
I have 2k * 1000 reocords in my table. Is it possible to bring the data based on by passing the page size.

Thanks in Advance


loving dotnet


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>