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 |
|
ajm22386
Starting Member
1 Post |
Posted - 2009-04-17 : 03:34:29
|
| Hi i have a users table with PKEY(Audit_user) this is referenced by every other table to track changes. I need to delete 200 users from users table without amending any other table? Im new to this really need help.Using sql server 2005Thanks so much.Joejoedahoe |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-17 : 03:42:51
|
BEGIN TRANDELETE auxFROM AuxiliaryTable AS AUXINNER JOIN Users AS u ON u.UserID = aux.UserIDWHERE u.FirstName = 'Whiskey'DELETE FROM Users WHERE FirstName = 'Whiskey'COMMIT TRAN E 12°55'05.63"N 56°04'39.26" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-17 : 10:12:58
|
| if you had created the foreign key with ON DELETE CASCADE then this removal would have happened automatically without you writing this removal logic for auxiliary tables |
 |
|
|
|
|
|