Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server-2008
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 28-Nov-11 4:24am
Edited 28-Nov-11 18:58pm
v3
Comments
Amir Mahfoozi at 28-Nov-11 11:46am
   
What your union statement is? Please provide it.
Eduard Lu at 29-Nov-11 0:48am
   
define save
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You could use a View, something like this:
 
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.
  Permalink  
v2
Comments
Marcus Kramer at 30-Nov-11 15:02pm
   
+5. Absolutely correct.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

create view temp
as
SELECT DistrictID,ECDName FROM ECD
UNION
SELECT DistrictID,SchoolName FROM Schools
  Permalink  
Comments
Marcus Kramer at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 424
1 Nirav Prabtani 298
2 OriginalGriff 199
3 _Amy 165
4 Maciej Los 145
0 OriginalGriff 7,755
1 Sergey Alexandrovich Kryukov 6,951
2 Maciej Los 3,994
3 Peter Leow 3,698
4 CHill60 2,742


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 30 Nov 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100