Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write the SQL sample code for querying Table dictionary data in SQL Server

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

SQL Server Table dictionary data query SQL sample code how to write, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Preface

The database contains four types of data:

1. User data

two。 Meta data

3. Indexes

4. Apply metadata

Among them, metadata is also called data dictionary and is defined as follows:

The following article is going to share with you a SQL statement about querying the SQL Server Table structure.

T-SQL is as follows:

SELECT (case when a.colorder=1 then d.name else''end) table name, a.colorder field serial number, a.name field name, (case when a.colorder=1 then isnull (f. Valuememe') else''end) table description, (case when COLUMNPROPERTY (a.iddepartment a.namememery) = 1 then' 1'else'0' end) identification (case when (SELECT count (*) FROM sysobjectsWHERE (name in (SELECT name FROM sysindexesWHERE (id = a.id) AND (indid in (SELECT indid FROM sysindexkeysWHERE (id = a.id) AND (colid in (SELECT colid FROM syscolumns WHERE (id = a.id) AND (name = a.name) AND (xtype = 'PK')) primary key, b.name type, a.length occupies bytes, COLUMNPROPERTY (a.idmatia. Namee Last PRECISN') as length Isnull (COLUMNPROPERTY (a. 1'else a. Name), 0) as decimal places, (case whena.isnullable=1 then '1'else' 0' end) allows null, isnull (e.textpaper') default value, isnull (g. [value] '') AS [description] FROM syscolumns aleft join systypes b on a.xtype=b.xusertypeinner join sysobjects d on a.id=d.id and d.xtypewritten tables U' and d.name'dtproperties'left join syscomments e on a.cdefault=e.idleft join sys.extended_properties g on a.id=g.major_id AND a.colid=g.minor_idleft join sys.extended_properties f on d.id=f.major_id and f.minor_id=0--where b.name is not nullWHERE d.nameplates database servers'- if only the specified table is queried Add this condition After reading the above, have you mastered how to write the query SQL sample code for Table dictionary data in SQL Server? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report