SQL Server guides
Practical fixes and patterns for SQL Server automation, written from the scripts in SQL Rig for SQL Server.
- Fix Msg 15002: sp_addlinkedserver cannot be executed within a transaction
Why sp_addlinkedserver fails with Msg 15002 inside BEGIN TRAN, and a safe, idempotent way to create a linked server with TRY/CATCH cleanup instead. - Fix Msg 156: incorrect syntax near the keyword 'CASE' in EXEC parameters
Why EXEC dbo.Proc @p = CASE ... END fails with Msg 156, incorrect syntax near the keyword CASE, and three correct ways to pass a computed value. - Safe batched DELETE in SQL Server, with a dry run
How to delete millions of rows in SQL Server safely: DELETE TOP (N) in short transactions, a @DryRun default, row caps, progress logging, and log-growth notes. - How to make AI coding agents safe on SQL Server
Practical guardrails for using Cursor, Claude Code, and GitHub Copilot with SQL Server: rules files, least-privilege logins, dry-run defaults, -WhatIf, and review checklists.