Formatting T-SQL consistently means choosing a few readable rules, using a formatter carefully, and keeping historical changes focused.
Waiting for an Agent Job to Finish Before the Next Step Runs
Wait for an Agent job to finish by polling its current sysjobactivity row, enforcing a timeout, and checking sysjobhistory outcome.
SQL SERVER – Backup and Restore Database Using Command Prompt – SQLCMD
Good DBAs automate the boring work. Here is a simple script to run Backup and Restore of a database from the command prompt with SQLCMD.
Warning Before SQL Login Passwords Expire With DaysUntilExpiration
A Friday-night login failure is avoidable. One small query warns you weeks ahead, if somebody owns the warning.
Generating Random Numbers Per Row: RAND, NEWID and CRYPT_GEN_RANDOM
Generate random numbers per row with NEWID or CRYPT_GEN_RANDOM, compare seeded RAND, inspect bucket spread, and pick a row without a sort.
SQL SERVER – Difference Between NOLOCK and NOWAIT Hints
Should you use NOLOCK when NOWAIT errors out on a lock? Here is the difference between NOLOCK and NOWAIT, and why neither guarantees a valid answer.
SQL SERVER – Significance of Table Input Parameter to Stored Procedure
Pass a whole table into a stored procedure instead of forming and parsing XML. Here is why a table input parameter to stored procedure saves round trips.







