The COL_NAME function returns a column’s name when you give it a table’s object ID and the column’s ID. This post uses it to turn the column IDs in index views into names, shows why a column ID is not a position once a column has been dropped, and explains the trap that returns a wrong name when the table lives in another database.
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.
SQL SERVER – View Column Dependencies and Output Columns
To Identify Columns used in a view, I distinguish references from returned output columns. Those lists answer different questions.
EXECUTE AS LOGIN vs EXECUTE AS USER: Where Impersonation Stops
Your test passed as a user, yet the sales team still gets an error. Here is where each kind of impersonation stops, and how to get back out.
Finding User Objects in master Created by Accident
Find user objects in master, inspect their purpose and dependencies, and prepare a safe move without removing deliberate server helpers.





