TRUNCATE TABLE should support truncating multiple tables to make it easier to delete hierarchies with foreign keys
Imagine the following tables: Customers and Orders. Clearly, Orders are foreign key dependent on Customers. Therefore, we cannot truncate the Customers table.
Truncate should support truncating multiple tables. This way we can delete the whole hierarchy at once. FK references within the set of truncated tables would be ignored.
TRUNCATE TABLE Customers, Orders
This should be reasonably cheap to implement. SQL Server just needs to lock all tables involved, truncate in a loop and ignore FKs within the set of tables to be deleted.
Upvotes: 2<=-=Mar 21 2017 1:07PM=-=>
Thank you for your feedback!
We will consider this feature for the future releases of SQL Server and Azure SQL Database.