View Full Version : Delete from linked tables
08-19-2005, 04:41 PM
Is it possble to delete all records from a table and all records in a second table that are linked to that record?
08-19-2005, 05:05 PM
You can use something like:
table1.id = table2.t1_id
id = x
08-19-2005, 05:23 PM
hmm, didnt work.. probably just another crappy SQL Server thing... rarrr
08-19-2005, 05:25 PM
What version are you on? It'll only work on version 4.0 and up.
08-19-2005, 05:26 PM
SQL Server 7
08-20-2005, 12:08 AM
Ah. That code's for MySQL; I don't think SQL Server supports it at all. You should be able to use 'ON DELETE CASCADE' in your table definitions, but you'll need to check the docs for specifics -- I don't feel qualified to say much more than that.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.