SELECT * FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='Account' SELECT (case when a.colorder=1 then d.name else '' end) as 表名,--如果表名相同就返回空 a.colorder as 字段序号, a.name as 字段名, (case when COLUMNPROPERTY( a.id,a.name,'IsIdentity'…
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='subject' --表名 1.利用sysobjects系统表 在这个表中,在数据库中创建的每个对象(例如约束.默认值.日志.规则以及存储过程)都有对应一行,我们在该表中筛选出xtype等于U的所有记录,就为数据库中的表了. 示例语句如下: select * from sysobjects where xtype='U' 注意:在SQL SERVER2005中,出现了sys.ob…
SELECT (case when a.colorder=1 then d.name else null end) 表名, a.colorder 字段序号,a.name 字段名, (case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end) 标识, (case when (SELECT count(*) FROM sysobjects WHERE (name in (SELECT name FROM…
原文地址:http://blog.csdn.net/pukuimin1226/article/details/7687538 ----查询数据库中用户创建的表 ----jsj01 为数据库名 select name tablename from jsj01..sysobjects where type='U' and name not in ('dtproperties') --查询表里的字段信息 exec sp_help 对象名 ---docs为表名 select * from syscolu…
方法一: SELECT a.name,b.rows FROM sysobjects a INNER JOIN sysindexes b ON a.id=b.id ,) AND a.Type='u' ORDER BY b.rows desc 方法二: ), RowCnt INT) EXEC sp_MSforeachtable 'INSERT INTO #temp SELECT ''?'', COUNT(*) FROM ?' select * from #temp order by RowCnt d…
查询数据库里所有表名和字段名的语句SQL 查询所有表名:SELECT NAME FROM SYSOBJECTS WHERE TYPE='U'SELECT * FROM INFORMATION_SCHEMA.TABLES查询表的所有字段名:SELECT NAME FROM SYSCOLUMNS WHERE ID=OBJECT_ID(' 表名' )SELECT * FROM INFORMATION_SCHEMA.TABLESSELECT * FROM INFORMATION_SCHEMA.VIEWS…