To get table data

I want to get all table names and fields in this table from a specific database. Please help me solve this problem.

+5
source share
2 answers

Try to look at the tables sys.objectsand sys.columns:

SELECT * FROM SYS.OBJECTS
WHERE TYPE = 'U'

Would give you all the tables in this database (Type U)

SELECT 'Table name : ' +  so.name, ' Column Name: ' + sc.name FROM SYS.OBJECTS so
INNER JOIN sys.columns sc ON sc.OBJECT_ID = so.OBJECT_ID
WHERE TYPE = 'U'

Gives you all the tables in this database and column names. You can filter these queries and doWHERE so.name = 'Your Table'

http://msdn.microsoft.com/en-us/library/ms190324.aspx

+3
source

use the syntax: -sp_help your table name

like this

sp_help Payroll_Shift

enter image description here

+2
source

All Articles