富贵资源网 Design By www.hznty.com
复制代码 代码如下:
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 = '表名'
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 = '表名'
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...