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

TRUNCATE TABLE should respect CASCADE foreign keys

Imagine the following tables: Customers and Orders. Clearly, Orders are foreign key dependent on Customers. Therefore, we cannot truncate the Customers table in the current SQL Server product.

But what if the foreign key connecting the two tables was configured as ON DELETE CASCADE? Then, we could simply truncate both tables at once. This would not violate the foreign key. Basically, "TRUNCATE TABLE Orders" would be a faster way to execute "DELETE FROM Orders" and semantically do the same thing. I don't see why this would not work.

I propose that TRUNCATE TABLE automatically follows CASCADE delete relationships.

1 vote
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