[dba-SQLServer] Deletion based on Compound Distinct Selection

Ron Moore rmoore at comtechpst.com
Thu Sep 23 13:34:40 CDT 2004


To All,

 

I've been hammering away at this for awhile and am under the gun now.  I am
trying to SELECT DISTINCT from 2 columns in table1, and use the return set
to DELETE all records in table2 where both of the same two columns are equal
to one of the distinct combinations in the return set.  I have tried using
the following which works for 1 column but not 2 columns:

 

DELETE

FROM

            DB2.dbo.TABLE2

WHERE COLUMN1,COLUMN2 IN (

                        SELECT DISTINCT COLUMN1,COLUMN2

                        FROM DB1.dbo.TABLE1 T1

                        )

 

Error is:             Line 4:   Incorrect syntax near ','.

 

Any thoughts?  I have the 'distinct' feeling I'm going about this the hard
way!

TIA,

Ron




More information about the dba-SQLServer mailing list