Tuesday, May 24, 2011

SQL - Display All Tables & Columns

Just as a reminder for those databases that you inherit that lack any sort of documentation....

SELECT SO.NAME AS table_name, SC.NAME AS column_name
FROM SYS.OBJECTS SO INNER JOIN SYS.COLUMNS SC
ON SO.OBJECT_ID = SC.OBJECT_ID
WHERE SO.TYPE = 'U'
ORDER BY SO.NAME, SC.NAME

No comments: