• I like the ides of this, I would add ordering the columns as they are defined in the key. And for the programmers in my area I would add a statement in the where clause so they only got the table they need instead of every table on the database.

    SELECT p.TABLE_NAME, c.CONSTRAINT_NAME, c.COLUMN_NAME

    FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS p

    inner join INFORMATION_SCHEMA.KEY_COLUMN_USAGE c on

    c.TABLE_NAME = p.TABLE_NAME

    AND c.CONSTRAINT_NAME = p.CONSTRAINT_NAME

    WHERE CONSTRAINT_TYPE = 'PRIMARY KEY'

    AND p.TABLE_NAME = 'name_here'

    ORDER by c.TABLE_NAME, c.ordinal_position

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.