SQL Server 查看表结构
SELECT distinct TABLE_NAME=d.name, COLUMN_NAME=A.name,DATA_TYPE = B.name,CHAR_LENGTH=A.length,DATA_PRECISION=A.xprec,DATA_SCALE=A.xscale,NULLABLE = Case When A.isnullable=1 Then 'NULL' Else 'NOTNULL' End,PRIMARY_KEY = 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 'YES' else 'NO' endFROMsyscolumns ALeft Joinsystypes BOnA.xusertype=B.xusertypeInner Joinsysobjects DOnA.id=D.id and D.xtype='U' and D.name<>'dtproperties'Left Joinsyscomments EonA.cdefault=E.idLeft Joinsys.extended_properties GonA.id=G.major_id and A.colid=G.minor_idLeft Joinsys.extended_properties FOnD.id=F.major_id and F.minor_id=0where upper(d.name) in ('TABLENAME')and A.name<> '__$command_id'
如果觉得《SQL Server 查看表结构》对你有帮助,请点赞、收藏,并留下你的观点哦!