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 2008 Forums
 Other SQL Server 2008 Topics
 Union Within procedure

Author  Topic 

Mayur Dhumal
Starting Member

4 Posts

Posted - 2011-11-11 : 07:11:27
Hi Guys,

I have written a procedure but i am getting all common data withing all tables, but what can be done, if i want to get all matched as well as unmatched data from stored procedure.

plz help with this issue.

thanx in advance.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-11 : 07:17:48
you need to use LEFT/RIGHT/FULL OUTER JOIN depending on scenario. FOr more details post some sample data with tables structures and explain what you want

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Mayur Dhumal
Starting Member

4 Posts

Posted - 2011-11-11 : 08:12:07
But even after using right & left outer join, i am getting the same data i.e matched data, but i am unable to get unmatched data.
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-11-11 : 08:27:59
Can you post a sample so that we can see what you are doing.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-11 : 08:57:50
quote:
Originally posted by Mayur Dhumal

But even after using right & left outer join, i am getting the same data i.e matched data, but i am unable to get unmatched data.


that may be because you're using some filter conditions which involves columns from unmatched side table which might be causing the outer join to reduce to inner join.
Again, to suggest more, we need to see your query and also need to have an idea of how data is there in your tables.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -