Click here to Skip to main content
15,903,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi i am making a stored procedure with multiple select statements when i execute them than different resultset are maken for each select statement all i need is to get one resultset from all select statements of sql quries in the stored procedure......HERE is the SP code..
MS SQL Syntax (Toggle Plain Text)
SQL
SET NOCOUNT ON;
 
      SELECT COUNT(*) AS totalEmployees FROM dbo.Add_Employees
 
	  SELECT DISTINCT dbo.Add_Employees.gender, COUNT(Add_Employees.employee_uniqueId) AS AccGender
	  FROM dbo.Add_Employees
	  GROUP BY(Add_Employees.gender)
 
	  SELECT DISTINCT dbo.Add_Employees.department, COUNT(Add_Employees.employee_uniqueId) AS Accdepartment
	  FROM dbo.Add_Employees
	  GROUP BY(Add_Employees.department)
 
 
	  SELECT DISTINCT dbo.Add_Employees.designation, COUNT(Add_Employees.employee_uniqueId) AS Accdesignation
	  FROM dbo.Add_Employees
	  GROUP BY(Add_Employees.designation)
 
	  SELECT DISTINCT dbo.Add_Employees.grade, COUNT(Add_Employees.employee_uniqueId) AS AccGrade
	  FROM dbo.Add_Employees
	  GROUP BY(Add_Employees.grade)
 
	  SELECT DISTINCT dbo.Add_Employees.country, COUNT(Add_Employees.employee_uniqueId) AS AccCountry
	  FROM dbo.Add_Employees
	  GROUP BY(Add_Employees.country)
 
	  SELECT DISTINCT dbo.Add_Employees.city, COUNT(Add_Employees.employee_uniqueId) AS AccCity
	  FROM dbo.Add_Employees
	  GROUP BY(Add_Employees.city)
 
 
END
Posted
Updated 16-Mar-12 4:31am
v2

1 solution

Look at
SQL
UNION 
or
SQL
UNION ALL
 
Share this answer
 
Comments
Mohammad Azeem 16-Mar-12 7:48am    
The problem is i have different number of columns and of different data type

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900