Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help with simple query

Author  Topic 

gregsenne
Starting Member

7 Posts

Posted - 2009-09-18 : 14:26:11
I want to run both queries below TOGETHER so they return the results together, and only show the distinct results from both.

SELECT DISTINCT NAME FROM TRIGGERS
SELECT DISTINCT NAME FROM TEMPLATES

Can I do this?

Thanks

patshaw
Posting Yak Master

177 Posts

Posted - 2009-09-18 : 14:49:41
select a.[name], b.[name]
from
(
SELECT DISTINCT NAME FROM TRIGGERS
) a,
(
SELECT DISTINCT NAME FROM TEMPLATES
) b
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-09-18 : 15:05:49
quote:
Originally posted by gregsenne

I want to run both queries below TOGETHER so they return the results together, and only show the distinct results from both.

SELECT DISTINCT NAME FROM TRIGGERS
SELECT DISTINCT NAME FROM TEMPLATES

Can I do this?

Thanks



SELECT DISTINCT NAME FROM TRIGGERS
union
SELECT DISTINCT NAME FROM TEMPLATES
Go to Top of Page

gregsenne
Starting Member

7 Posts

Posted - 2009-09-18 : 15:36:28
vijayisonly, THANKS! Worked perfectly
Go to Top of Page
   

- Advertisement -