A rename swaps names in a blink, yet the foreign key and permissions stay with the old table. Here is a short demo and a safer swap.
SQL SERVER – Puzzle – How Does Table Qualifier Work in INSERT Statement?
You can use a table alias in SELECT just fine, but how does a Table Qualifier work in the column list of an INSERT statement? Try this short puzzle.
SQL SERVER – Puzzle – Strange Behavior With Extra Comma in Create Table Statement
My favorite icebreaker puzzle: a strange behavior with an extra comma in CREATE TABLE statement. Why does SQL Server accept it for temp and regular tables?
ROWCOUNT and PAGECOUNT: Faking a Big Table to Test Plans
You can tell the optimizer a three-row table has 10 million rows and watch the plan change. Here is how, and how to undo it.
How to Check if a Column Exists in a SQL Server Table
To check if a column exists in a SQL Server table, call COL_LENGTH and test the result for NULL, or look the column up in sys.columns. This post compares the three common checks, including the schema trap in INFORMATION_SCHEMA and the three-part name for another database. It ends with a script that adds a column only when it is missing, and the batch rule that makes that script fail if you ignore it.
Magic Numbers in Code: Replacing Status Codes With a Lookup Table
Nobody remembers what the 3 means. Give each status code an approved name, let the database enforce it, and leave your data alone.
What is the Difference between TRUNCATE and DELETE in SQL Server? – Interview Question of the Week #118
What is the difference between TRUNCATE and DELETE in SQL Server? An interview question that never gets old, with a clear list of the differences.





