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 line of standing dominoes interrupted by one solid wooden block set across the run.

SQL SERVER – How to Use Instead of Trigger

January 24, 2013
Pinal Dave
SQL Tips and Tricks
SQL Scripts, SQL Server, SQL Trigger

Triggers come in two kinds, Instead of and After. Here is how an Instead of Trigger can intercept an insert, update or delete on a table, with an example.

Read More
Gouache painting: a wooden crate riding on a long luggage trolley through three open stone archways in a row, a small vermilion luggage tag tied to the crate's rope handle

CONTEXT_INFO: Passing a Value Through a Session

January 14, 2013
Pinal Dave
SQL Tips and Tricks
SQL Audit, SQL Scripts, SQL Trigger

CONTEXT_INFO lets you attach a small value to a session and read it anywhere in that session, even inside a trigger. This post tests SET CONTEXT_INFO on SQL Server 2025, uses it to log who changed a price, and compares it with SESSION_CONTEXT.

Read More
A hand holding a steel punch over a new silver spoon on an anvil, ready to stamp its maker's mark.

Audit Columns From Day One: CreatedAt, UpdatedAt and Who Changed It

October 17, 2012
Pinal Dave
SQL Tips and Tricks
SQL Audit, SQL Constraint and Keys, SQL DateTime, SQL Server, SQL Trigger

Add audit columns with UTC timestamps and trusted change identities, maintain updates in procedures, and know when history is needed.

Read More
A wooden door with three brass bells hanging on cords, each with a small red tassel.

Types of Triggers Quiz: Which Trigger Can Fire on a View?

January 3, 2012
Pinal Dave
SQL Puzzle
SQL Error Messages, SQL Table Operation, SQL Trigger, SQL View

This Types of Triggers Quiz asks which trigger you can put on a view that joins two tables. The answer is INSTEAD OF INSERT. A tested script shows the error an AFTER trigger gives and how the working trigger splits one insert into two tables.

Read More
Three states of a view of invoices over 2,000: five rows at the start, five rows after one update that subtracts 150, and four rows after a second run, with invoice 1 at 1,900 in the table but missing from the view

WITH CHECK OPTION in SQL Server: Stop Rows Leaving a View

August 24, 2011
Pinal Dave
SQL Tips and Tricks
SQL Error Messages, SQL Scripts, SQL Trigger, SQL View

WITH CHECK OPTION stops a change made through a view from pushing a row out of that view. This post builds a view of large invoices, shows an update and an insert that make rows vanish, adds the option to block both with Msg 550, and compares it with a trigger. Every result comes from SQL Server 2025.

Read More
A wooden abacus on a market stall counter, a hand sliding one red bead across for the day's final sale.

Summary Tables: Keeping Pre-Aggregated Totals Current

June 24, 2011
Pinal Dave
SQL Tips and Tricks
Data Warehousing, SQL Server, SQL Server Agent, SQL Trigger, SQL View

Keep summary tables current with changed-day rebuilds, handle late arrivals and deletes, and reconcile stored totals against detail.

Read More
Hands splicing two ropes together, one strand slipping loose

MERGE Statement Pitfalls

January 10, 2010
Pinal Dave
SQL Tips and Tricks
Output Clause, SQL Server, SQL Transactions, SQL Trigger

MERGE statement pitfalls include duplicate source keys, concurrency races, trigger surprises, and complex actions that deserve testing.

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

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