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 2000 Forums
 SQL Server Development (2000)
 Unique Rows

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-11 : 09:44:01
Dan writes "I have two seperate tables that have the same columns names. Each table contains about 8 different columns and roughly 1000 rows each. Each of these tables may or may not contain the same data in them. I want to select only rows that are different in each table regardless of what column the data was different in. Only rows that are unique would be returned. Would it be easier if the two tables were one table?"

andre
Constraint Violating Yak Guru

259 Posts

Posted - 2001-12-11 : 10:08:24
You might be better off merging them into 1 table, but I can't say for sure without knowing more about your tables.

You could get distinct rows from 2 tables using a UNION statement like this if the structure of the 2 tables are identical:

SELECT DISTINCT * FROM (
SELECT * FROM Table1
UNION
SELECT * FROM Table2
) S1



Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2001-12-11 : 10:30:52
union does a distinct anyway so this is the same as

SELECT * FROM Table1
UNION
SELECT * FROM Table2


==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -