List all tables with column details SQL Server

The below query can be run in a database on SQL Server to list all tables with column details.

SELECT schema_name(tab.schema_id) as schema_name, as table_name, 
    col.column_id, as column_name, as data_type,    
FROM sys.tables as tab
    INNER JOIN sys.columns as col
        on tab.object_id = col.object_id
    LEFT JOIN sys.types as t
    on col.user_type_id = t.user_type_id
ORDER BY schema_name,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.