How to list all the SQL Server database tables and their fields?

Raja
Posted by Raja under Sql Server category on | Views : 13878
To get the list of all the user created tables from the sql server database, use

select * from sys.tables where type = 'U'


To list the field names of the database table, use

SELECT [name] AS [Column name] FROM syscolumns WHERE id = (SELECT id  FROM
sysobjects WHERE type = 'U' AND [NAME] = 'your table name')


Listing all the fields of the user created table into the database, use

SELECT [name] AS [Column name] FROM syscolumns WHERE id in 
(SELECT id FROM sysobjects WHERE type = 'U')

Comments or Responses

Login to post response