列出数据库的所有表的创建时间
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 nvarchar(1000), tab nvarchar(1000),cdate datetime)declare c cursor forselect 'insert into tab_alltables (tab,db,cdate) select name,''' name ''',crdate from ' name '..sysobjects where xtype=''u''' from master..sysdatabases where dbid>4open cfetch c into @scriptwhile @@fetch_status=0beginexec (@script) print @scriptfetch c into @scriptendclose c deallocate cselect * from tab_alltables --You can add your criteria here to serach for a particular table nameend
这个SP将产生三列:
1) db: 数据库名称
2) tab : 表名称
3) cdate: 表的创建时间
下载地址
用户评论