I needed to get the column name for the primary key in a table - I am working on a migration just now (no great surprise there ;)) and I needed to get this column name in order to carry out some double posting (once in the new system and next in the old system).
It was surprisingly easy to do this
This simple piece of code gets the name of the column that is your primary key. Short and simple and a new one for myself.
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
WHERE TABLE_NAME = '