Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Self Referencing DELETE Query Deletes All Rows
Message
From
20/08/2004 16:50:43
Jason Dalio
Northern Interior Regional Health Board
Prince George, British Columbia, Canada
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00934181
Message ID:
00935049
Views:
34
I realize that the LEFT OUTER JOIN will grab all of the records from the ClientAddressHistory table but I have included a WHERE clause that limits the list to those with a NULL value in the Enrollment table (verified by the initial SELECT statement that only returns a subset of the result set). Despite this, all records are being deleted from the table.

If I run just the select subquey contained in the delete transaction in retuns 0 rows. If I then change the DELETE statement to a SELECT statement and run the entire query it select 3 rows. So what i can't figure out is why it is deleting all rows based on a ClientID IN statement when the subquery returns only a subset of the ClientID values.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform