系统试图(返回表所有记录数及所有的 identity 列)

--返回数据库的所有数据表所包含记录笔数,创建日期
use TestDB
select db_name(),
       sys.schemas.name,
       o.name,
       i.rows,
       o.crdate
from sys.sysobjects o
left join sys.sysindexes i on o.id=i.id and i.indid<=1
join sys.schemas on schema_id=uid
where Type='U'
--查询各数据表是否包含Identity 字段

select s.Name AS SchemaName,t.Name as tableName,
case when c.name is null then 'N' else 'Y' end,
c.NAME AS ColumnName
from sys.sysobjects t
left join sys.identity_columns c on object_Id=id
join sys.schemas s on schema_id=uid
where Type='U'

posted @ 2011-01-11 23:12  Alex Tian  阅读(160)  评论(0编辑  收藏  举报