In SQL Server 2005, can I do a cascade delete without setting the property on my tables?

前端 未结 13 1472
心在旅途
心在旅途 2020-12-12 17:02

I have a database full of customer data. It\'s so big that it\'s really cumbersome to operate on, and I\'d rather just slim it down to 10% of the customers, which is plenty

13条回答
  •  借酒劲吻你
    2020-12-12 17:34

    This script has two issues: 1. You must indicate the condition 1=1 in order to delete all table base. 2. This creates the direct relations with the base table only. If the final table has another table parent relation, the the delete fail

    DELETE FROM [dbo].[table2] WHERE TableID in (select [ID] from [dbo].[table3] where 1=1)

    If table2 has a parent relation table1

提交回复
热议问题