SQL obtains fields and corresponding descriptions based on the table name. For more information, see.
SQL obtains fields and corresponding descriptions based on the table name. For more information, see.
The Code is as follows:
SELECT
TableName = OBJECT_NAME (c. object_id ),
ColumnsName = c. name,
Description = ex. value,
ColumnType = t. name,
Length = c. max_length
FROM
Sys. columns c
LEFT OUTER JOIN
Sys. extended_properties ex
ON
Ex. major_id = c. object_id
AND ex. minor_id = c. column_id
AND ex. name = 'Ms _ description'
Left outer join
Policypes t
On c. system_type_id = t. xtype
WHERE
OBJECTPROPERTY (c. object_id, 'ismsshipped ') = 0
AND OBJECT_NAME (c. object_id) = 'tablename'
1. Get all database names:
Select Name FROM Master .. SysDatabases orDER BY Name
2. Get all table names:
Select Name FROM DatabaseName .. SysObjects Where XType = 'U' orDER BY Name
XType = 'U': indicates all user tables;
XType = 's': indicates all system tables;
3. Get all field names:
Select Name FROM SysColumns Where id = Object_Id ('tablename ')