SQLServer中列出数据库的所有表的创建时间
发布时间:2020-12-12 14:31:19 所属栏目:MsSql教程 来源:网络整理
导读:下面这个存储过程将列出数据库的所有表的创建时间: Create proc usp_alldatabasesasbegin declare @script as nvarchar(2000)if exists(select 1 from sysobjects where name='tab_alltables') drop table tab_alltablescreate table tab_alltables (db nvar
下面这个存储过程将列出数据库的所有表的创建时间: Create proc usp_alldatabases as begin declare @script as nvarchar(2000) if exists(select 1 from sysobjects where name='tab_alltables') drop table tab_alltables create table tab_alltables (db nvarchar(1000),tab nvarchar(1000),cdate datetime) declare c cursor for select 'insert into tab_alltables (tab,db,cdate) select name,'''+name+ ''',crdate from ' +name+'..sysobjects where xtype=''u''' from master..sysdatabases where dbid>4 open c fetch c into @script while @@fetch_status=0 begin exec (@script) print @script fetch c into @script end close c deallocate c select * from tab_alltables --You can add your criteria here to serach for a particular table name end 这个SP将产生三列: 1) db: 数据库名称 2) tab : 表名称 3) cdate: 表的创建时间 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |