Click here to Skip to main content
15,886,845 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
How can I save Union in SQL so that I can link it with a Dropdownlist? pls help

This is my Union Statement

SELECT DistrictID,ECDName FROM ECD
UNION
SELECT DistrictID,SchoolName FROM Schools

save as in where do you store it in SQL under storprocedures, view, tables.where?
Posted
Updated 28-Nov-11 18:58pm
v3
Comments
Amir Mahfoozi 28-Nov-11 11:46am    
What your union statement is? Please provide it.
[no name] 29-Nov-11 0:48am    
define save

You could use a View, something like this:

SQL
CREATE VIEW [Your_View_Name]
AS
SELECT DistrictID, ECDName as Name FROM ECD
UNION
SELECT DistrictID, SchoolName as Name FROM Schools


It is stored under Views.
 
Share this answer
 
v2
Comments
fjdiewornncalwe 30-Nov-11 15:02pm    
+5. Absolutely correct.
Hi MBalentle,

In my opinion converting it to a StoredProcedure is better because if the need for some filtering arises you can simply pass some parameters to that stored procedure and adapt that storedprocedure to the new requirements.
 
Share this answer
 
create view temp
as
SQL
SELECT DistrictID,ECDName FROM ECD
UNION
SELECT DistrictID,SchoolName FROM Schools
SQL

 
Share this answer
 
Comments
fjdiewornncalwe 30-Nov-11 15:02pm    
Sorry, but create a temp view is a huge waste of resources for this. Solution 1 is the correct way to deal with this.

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