Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Make delete statement with 30 equalities more efficient

$
0
0
I am working on a statement that deletes records from one table where 30 fields match in value with at least one record in another table. My initial statement was:delete <tablename> afrom <secondtablename> bwhere a.field1 = b.field1and a.field2 = b.field2........and a.field30 = b.field30I need something more efficient, so I then tried the following, but the performance was even worse:delete <tablename> awhere exists( select a.field1, a.field2.........a.field30 intersect select b.field1, b.field2.........b.field30 from <secondtablename> b)The structure of the tables cannot be changed. Can someone please suggest a more efficient method to accomplish this task?

Viewing all articles
Browse latest Browse all 3145

Trending Articles