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
 General SQL Server Forums
 New to SQL Server Programming
 Question on Temp Tables

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2007-11-05 : 14:50:03
Does anyone know how to compare two temp tables using a left outer join? I have to find the diferences between Temp Table A and Temp Table B.

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2007-11-05 : 15:13:21
I tried the following Select statement but is incorrect. I will apreciate if anyone can help me out in the comparison of the two temp tables.

Thanks!!!!




Select a.station_nbr, a.station_name,a.group_code, a.beg_eff_date_DGC, a.end_eff_date_DGC,
b.beg_eff_date_SES, b.end_eff_date_SES
INTO #TP_DGC_vs_SES
From #TP_DGC a left outer join #TP_SES b
on a.station_nbr=b.station_nbr and a.group_code = b.group_code
#TP_SES c left outer join #TP_DGC d
on c.station_nbr=d.station_nbr and c.group_code = d.group_code
WHERE (a.group_code = b.group_code)
and(a.station_nbr = b.station_nbr)
and (b.station_nbr is not Null)

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-11-05 : 15:31:12
I think people are reluctant to help you based on your past history and modus operandi.
Read about FULL JOIN in Books Online.

You also asked same question three days ago here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=91994



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-05 : 18:58:36
a basic syntax for this will be

select *
from tablea a full outer join tableb b
on a.key_col = b.key_col
where a.col1 <> b.col1
or a.col1 is null
or b.col1 is null
or a.col2 <> b.col2
or a.col2 is null
or b.col2 is null



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-11-05 : 19:04:53
SQL Server 2005 technique: http://weblogs.sqlteam.com/jeffs/archive/2007/05/02/60194.aspx

SQL Server 2000 technique: http://weblogs.sqlteam.com/jeffs/archive/2003/10/03/244.aspx



Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -