Print a table structure in SQL Server

I was wondering how it’s possible to get the structure of one or more table(s) in a database, using possibly a SELECT; I need to retrieve the composition of the DB I’m working onto to attach it in some docs about the webapp I’m currently developing.

SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH 
FROM INFORMATION_SCHEMA.COLUMNS ORDER BY TABLE_NAME
Leave a comment

Send a Comment

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