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.
| Author |
Topic |
|
rodcon
Starting Member
1 Post |
Posted - 2008-04-10 : 21:32:57
|
| I am trying to delete a specific record where it does not exist in another related tableex. delete a registration if it does not have an associated invoiceALTER PROCEDURE dbo.DeleteRegistrationByRegistrationID(@registrationID int)AsDelete @registrationIDFrom registrations Where registrations.registrationIDNOT IN (SELECT invoices.registrationIDFROM invoicesWHERE invoices.registrationID = @registrationID); |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-10 : 22:37:10
|
| Try this:DELETE FROM Registrations rWHERE NOT EXISTS (SELECT * FROM Invoices i WHERE r.registrationID = i.registrationID) AND registrationID = @registrationIDTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
|
|
|