tag:blogger.com,1999:blog-16771259.post115133293728755145..comments2024-03-07T03:02:45.934-08:00Comments on SQL Server Code,Tips and Tricks, Performance Tuning: DELETE and Subquery (IN) ProblemUnknownnoreply@blogger.comBlogger1125tag:blogger.com,1999:blog-16771259.post-1151405913761492492006-06-27T03:58:00.000-07:002006-06-27T03:58:00.000-07:00HiI would recommend you to use the ANSI-92 syntax ...Hi<BR/><BR/>I would recommend you to use the ANSI-92 syntax to delete referenced values from a table:<BR/><BR/><BR/><BR/>CREATE TABLE Table1 (ID INT)<BR/>GO<BR/>CREATE TABLE Table2 (ID INT)<BR/>GO<BR/><BR/>INSERT INTO Table1 VALUES (1)<BR/>INSERT INTO Table1 VALUES (2)<BR/>INSERT INTO Table1 VALUES (3)<BR/>INSERT INTO Table2 VALUES (1)<BR/>GO<BR/><BR/>DELETE T1<BR/> FROM Table1 T1<BR/> JOIN Table2 T2 ON T1.ID = T2.ID<BR/><BR/><BR/>Advantages:<BR/>* No wrong deleted values in case of an error<BR/>* More than one possible criteria column<BR/>* Tidy statement, cause the JOIN between the tables is a really JOIN and no part of the WHERE<BR/><BR/>Greets<BR/>Florian ReischlAnonymousnoreply@blogger.com