SQL 数据结构查询

时间:2024-11-05 07:00:36

1:查询变得结构。

SELECT COLID,SO.NAME,EP.VALUE,SO.LENGTH,MIN(ST.NAME) AS TYPE      

FROM  SYS.EXTENDED_PROPERTIES EP      
      
RIGHT JOIN SYS.SYSCOLUMNS SO ON MAJOR_ID=ID AND COLID=MINOR_ID      
      
LEFT JOIN SYS.SYSTYPES ST ON ST.XTYPE=SO.XTYPE      
      
WHERE      
      
ID=OBJECT_ID('HQC_SCJY_TZZXtianbao')      
      
GROUP BY COLID,SO.NAME,EP.VALUE,SO.LENGTH

2:在创建表时添加注释

EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'外键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HQC_KJGL_LXshenqing_list', @level2type=N'COLUMN',@level2name=N'HQC_KJGL_LXshenqing_ID';