Posts Query to list all tables and columns in database
Post
Cancel

Query to list all tables and columns in database

Here is the SQL query that will help you list all the tables and columns along with its data type and length in a particular database.

This query fires query to the system table that stores all the information about the database.

select table_name, column_name, data_type, character_maximum_length, is_nullable from information_schema.columns where table_name in (select name from sysobjects where xtype='U') order by table_name

Hope this helps, enjoy

This post is licensed under CC BY 4.0 by the author.