Do you have a comment or suggestion to improve SQL Server? We’d love to hear it!

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.

2 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)

    We’ll send you updates on this idea

    AdminMicrosoft SQL Server (Admin, Microsoft Azure) shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    0 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base