复制代码代码如下:SELECTNameFROMMaster.
SELECT Name FROM Master..SysDatabases ORDER BY Name --获得所有数据库
SELECT Name FROM [数据库名]..SysObjects Where XType='U' ORDER BY Name --获得数据库下的所有表
select name from syscolumns where id=object_id(N'表名') --获得表里的所有字段
--获取表字段名、类型、递增、描述
select syscolumns.name as 字段,syscolumns.isnullable as 可否为空,systypes.name as SQL类型,
ISNULL(sys.identity_columns.is_identity,0) as 递增,
ISNULL(sys.extended_properties.value,'') as 描述 from sysobjects
join syscolumns on sysobjects.id = syscolumns.id
join systypes on syscolumns.xusertype = systypes.xusertype
left join sys.identity_columns on sys.identity_columns.object_id = syscolumns.id
and sys.identity_columns.column_id = syscolumns.colid
left join sys.extended_properties on sys.extended_properties.major_id = syscolumns.id
and sys.extended_properties.minor_id = syscolumns.colid
where sysobjects.name = '表名'
声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!