Request: Safe Updates Feature in SQL

Mohammad.safyar 0 Reputation points
2025-02-20T15:40:18.7433333+00:00

This feature prevents UPDATE or DELETE queries from executing unless they include a WHERE clause or a LIMIT. It's a safeguard against accidental table-wide modifications and helps maintain data integrity.

I believe SQL Server would greatly benefit from a similar feature. Here's how it might work:

  • SET SAFE_UPDATES ON; → Blocks UPDATE and DELETE without WHERE or TOP clauses.
  • SET SAFE_UPDATES OFF; → Disables this restriction.
  • The setting could apply per session, per database, or globally.

Currently, SQL Server users rely on triggers or policies to achieve this behavior, which is cumbersome compared to a built-in option.

Does SQL Server have a similar feature or workaround? If not, would Microsoft consider adding this in a future release?

SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
119 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 117.4K Reputation points MVP
    2025-02-20T22:10:36.3066667+00:00

    No, there is nothing in SQL Server that fits this request.

    The place to file suggestions like this is https://feedback.azure.com/d365community/forum/04fe6ee0-3b25-ec11-b6e6-000d3a4f0da0

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.