当前位置:网站首页>sql server 查询指定表的表结构
sql server 查询指定表的表结构
2022-07-03 02:33:00 【Lee魅儿】
SELECT
表名 = 'dbo.Treestructure',
表说明 = CASE WHEN A.COLORDER=1 THEN ISNULL(F.VALUE,'') ELSE '' END,
字段序号 = A.COLORDER,
字段名 = A.NAME,
自增标识 = CASE WHEN COLUMNPROPERTY( A.ID,A.NAME,'ISIDENTITY')=1 THEN '√'ELSE '' END,
主键 = CASE WHEN EXISTS(SELECT 1 FROM SYSOBJECTS WHERE XTYPE='PK' AND PARENT_OBJ=A.ID AND NAME IN (
SELECT NAME FROM SYSINDEXES WHERE INDID IN(
SELECT INDID FROM SYSINDEXKEYS WHERE ID = A.ID AND COLID=A.COLID))) THEN '√' ELSE '' END,
数据类型 = B.NAME,
占用字节数 = A.LENGTH,
长度 = COLUMNPROPERTY(A.ID,A.NAME,'PRECISION'),
小数位数 = ISNULL(COLUMNPROPERTY(A.ID,A.NAME,'SCALE'),0),
是否可空 = CASE WHEN A.ISNULLABLE=1 THEN '√'ELSE '' END,
默认值 = ISNULL(E.TEXT,''),
字段说明 = ISNULL(G.[VALUE],'')
FROM
SYSCOLUMNS A
LEFT JOIN SYSTYPES B ON A.XUSERTYPE=B.XUSERTYPE
INNER JOIN SYSOBJECTS D ON A.ID=D.ID AND D.XTYPE='U' AND D.NAME<>'DTPROPERTIES'
LEFT JOIN SYSCOMMENTS E ON A.CDEFAULT=E.ID
LEFT JOIN sys.extended_properties G ON A.ID=G.major_id AND A.COLID=G.minor_id
LEFT JOIN sys.extended_properties F ON D.ID=F.major_id AND F.minor_id=0
where
D.name = 'Treestructure'
ORDER BY D.NAME,A.ID,A.COLORDER
边栏推荐
- 通达OA 首页门户工作台
- Classes and objects - initialization and cleanup of objects - constructor call rules
- 内存池(内核角度理解new开辟空间的过程)
- Su Shimin: 25 principles of work and life
- Detailed introduction to the deployment and usage of the Nacos registry
- Oauth2.0 authentication, login and access "/oauth/token", how to get the value of request header authorization (basictoken)???
- Exception handling in kotlin process
- 【翻译】Flux安全。通过模糊处理获得更多信心
- Gbase 8C system table PG_ am
- Simple understanding of SVG
猜你喜欢

What does "where 1=1" mean

Thread safe singleton mode

Flink CDC mongoDB 使用及Flink sql解析monggo中复杂嵌套JSON数据实现
[advanced ROS] Lesson 6 recording and playback in ROS (rosbag)

Principle and application of database

Coroutinecontext in kotlin

MATLAB小技巧(24)RBF,GRNN,PNN-神经网络

random shuffle注意
![[fluent] listview list (map method description of list set | vertical list | horizontal list | code example)](/img/e5/c01f760b07b495f5b048ea367e0c21.gif)
[fluent] listview list (map method description of list set | vertical list | horizontal list | code example)

Random Shuffle attention
随机推荐
【教程】chrome关闭跨域策略cors、samesite,跨域带上cookie
My creation anniversary
微服务组件Sentinel (Hystrix)详细分析
Apple releases MacOS 11.6.4 update: mainly security fixes
Interview stereotyped version
COM和CN
Basic operation of binary tree (C language version)
GBase 8c系统表-pg_constraint
Detailed introduction to the deployment and usage of the Nacos registry
Monitoring and management of JVM
[fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)
Restcloud ETL cross database data aggregation operation
awk从入门到入土(3)awk内置函数printf和print实现格式化打印
Awk from entry to burial (1) awk first meeting
HTB-Devel
[codeforces] cf1338a - Powered addition [binary]
COM and cn
Awk from introduction to earth (0) overview of awk
[tutorial] chrome turns off cross domain policies CORS and samesite, and brings cookies across domains
[fluent] listview list (map method description of list set | vertical list | horizontal list | code example)