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.
| Author |
Topic |
|
jeff06
Posting Yak Master
166 Posts |
Posted - 2007-01-22 : 09:38:30
|
| t2 is a subset of t1, I want t1-t2.but following code does not seem to work.SELECT *FROM t1exceptselect * from t2How to fix this problem? Thanks. |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2007-01-22 : 09:40:54
|
| SELECT t1.*FROM t1LEFT JOIN t2On t1.keyField = t2.keyFieldWHERE t2.keyField is NULL |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-22 : 09:41:52
|
is t1 & t2 has the same structure ?else specify the column name select col1, col2 from t1exceptselect cola, colb from t2 KH |
 |
|
|
jeff06
Posting Yak Master
166 Posts |
Posted - 2007-01-22 : 09:48:20
|
| Yes t1 and t2 has same structure |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-22 : 09:52:30
|
any error message ? KH |
 |
|
|
jeff06
Posting Yak Master
166 Posts |
Posted - 2007-01-22 : 11:42:42
|
| russell's method works.Thanks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-22 : 11:46:40
|
| are you not using SQL Server 2005, as the forum name hint?Peter LarssonHelsingborg, Sweden |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2007-01-22 : 12:37:45
|
| there is no significant difference between the two. a look at exec plan will show similar cost and same steps, i/o, cpu record counts.both plans will show a merge join, though left join will show "left join" and except will show "left anti semi join"at least this is true on the few trials i have run |
 |
|
|
|
|
|