This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
A chessboard mid-game on a cafe table with empty chairs, one knight off its square, two cold cups of coffee.

Who Changed This Row? Auditing Data Changes

June 10, 2015
Pinal Dave
SQL Tips and Tricks
Change Data Capture, SQL Audit, SQL Server, SQL Trigger, Temporal Table

Auditing data changes requires choosing whether you need old values, new values, actor identity, or a change feed, then testing the cost.

Read More
SQL Server Management Studio.

SQL SERVER – Restricting Access to Contained Databases using Logon Triggers

November 18, 2014
Pinal Dave
SQL Tips and Tricks
SQL Trigger

Restricting access to contained databases: a DBA friend wanted to limit which users can connect, and logon triggers can do that. Here is how.

Read More
Upside-down glazed bowl showing its original clay foot ring

Audit Triggers That Record the Real User Behind EXECUTE AS

October 28, 2014
Pinal Dave
SQL Tips and Tricks
SQL Audit, SQL Server Security, SQL Trigger

Your audit table says dbo for every change, and nobody can tell who really did it. Here is how to capture the person behind EXECUTE AS.

Read More
A spring catch holds one gate closed while a neighboring gate stays open

A Server Trigger That Blocks Accidental Database Drops

November 18, 2013
Pinal Dave
SQL Tips and Tricks
DBA, SQL Backup and Restore, SQL Trigger

A server trigger can turn a wrong-tab DROP DATABASE into an error message. Here is a small demo that guards one name and removes itself at the end.

Read More
A rose branch pressing a red doorbell in the wind with nobody at the door.

UPDATE() in a Trigger Is True Even When Nothing Changed

September 21, 2013
Pinal Dave
SQL Tips and Tricks
SQL Audit, SQL NULL, SQL Server, SQL Trigger

Understand why UPDATE() in a trigger fires for unchanged SET values and log only real changes with inserted and deleted row comparisons.

Read More
A diagram of order statuses: New, Paid, Packed, Shipped and Delivered in a row, Cancelled below, and a red dashed arrow from New to Shipped marked as rejected with Msg 50001 and the text Status change not allowed: order 4 New to Shipped

State Machine in T-SQL: Allowed Status Changes for an Order

July 22, 2013
Pinal Dave
SQL Tips and Tricks
SQL Constraint and Keys, SQL Scripts, SQL Transactions, SQL Trigger

A state machine in T-SQL keeps the allowed status changes in a table and rejects every other change. This post builds one for orders with a transitions table and a trigger, then tests a bad jump, several rows in one UPDATE, new orders, a transaction and a new rule. Every result comes from SQL Server 2025.

Read More
A cat with a red collar passes through a cat flap while a stray waits outside.

Enforcing Object Naming Rules With a DDL Trigger

June 8, 2013
Pinal Dave
SQL Tips and Tricks
SQL Coding Standards, SQL Server, SQL Trigger

Enforce procedure and index names with a DDL trigger, inspect EVENTDATA, audit rejected attempts, and list existing violations.

Read More
Previous 1 2 3 4 5 6 7 8 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com