Copy codeThe Code is as follows:
SELECT Name FROM Master... SysDatabases order by Name -- get all databases
SELECT Name FROM [database Name]... SysObjects Where XType = 'U' order by Name -- get all tables in the database
Select name from syscolumns where id = object_id (N 'table name') -- obtain all fields in the table
-- Obtain the table field name, type, increment, and description.
Copy codeThe Code is as follows:
Select syscolumns. name as field, can syscolumns. isnullable as be empty, policypes. name as SQL type,
ISNULL (sys. identity_columns.is_identity, 0) as increments,
ISNULL (sys. extended_properties.value, '') as description from sysobjects
Join syscolumns on sysobjects. id = syscolumns. id
Join policypes on syscolumns. xusertype = policypes. xusertype
Left join sys. identity_columns on sys. identity_columns.object_id = syscolumns. id
And sys. identity_columns.column_id = syscolumns. colid
Left join sys. extended_properties on sys. extended_properties.major_id = syscolumns. id
And sys. extended_properties.minor_id = syscolumns. colid
Where sysobjects. name = 'table name'