Copy codeThe Code is as follows:
Create view dbo. vw_db_dictionary
AS
Select top 100 PERCENT dbo. sysobjects. name AS table_name,
Dbo. sysproperties. [value] AS table_desc, dbo. syscolumns. name AS field,
Properties. [value] AS field_desc, dbo. policypes. name AS field_type,
Dbo. syscolumns. length AS field_size,
ISNULL (COLUMNPROPERTY (dbo. syscolumns. id, dbo. syscolumns. name, 'Scale'), 0)
AS field_precision, dbo. syscolumns. isnullable AS nullable,
Case when syscomments. text IS NULL
THEN ''else syscomments. text end as default_value,
Case when columnproperty (syscolumns. id, syscolumns. name, 'isidentity ')
= 1 THEN '√ 'else' 'end AS is_identity, CASE WHEN EXISTS
(SELECT 1
FROM sysobjects
WHERE xtype = 'pk' AND name IN
(SELECT name
FROM sysindexes
WHERE indid IN
(SELECT indid
FROM sysindexkeys
WHERE id = syscolumns. id AND colid = syscolumns. colid )))
THEN '√ 'else' 'end AS is_key
FROM dbo. syscolumns INNER JOIN
Dbo. sysobjects ON dbo. sysobjects. id = dbo. syscolumns. id INNER JOIN
Dbo. policypes ON dbo. syscolumns. xtype = dbo. policypes. xtype LEFT OUTER JOIN
Dbo. sysproperties properties ON dbo. syscolumns. id = properties. id AND
Dbo. syscolumns. colid = properties. smallid LEFT OUTER JOIN
Dbo. sysproperties ON dbo. sysobjects. id = dbo. sysproperties. id AND
Dbo. sysproperties. smallid = 0 LEFT OUTER JOIN
Dbo. syscomments ON dbo. syscolumns. cdefault = dbo. syscomments. id
WHERE (dbo. sysobjects. xtype = 'U ')
Order by dbo. sysobjects. name