下面这个存储过程将列出数据库的所有表的创建时间: 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 (d
下面这个存储过程将列出数据库的所有表的创建时间:
Create proc usp_alldatabases
<span>as</span>
begin
 
declare @script <span>as</span> nvarchar(2000)
<span>if</span> exists(select 1 from sysobjects <span>where</span> name=<span>'tab_alltables'</span>) drop table tab_alltables
create table tab_alltables (db nvarchar(1000), tab nvarchar(1000),cdate datetime)
declare c cursor <span>for</span>
select <span>'insert into tab_alltables (tab,db,cdate) select name,'</span><span>''</span>+name+ <span>''</span><span>',crdate from '</span> +name+<span>'..sysobjects where xtype='</span><span>'u'</span><span>''</span> from master..sysdatabases <span>where</span> dbid>4
open c
fetch c into @script
<span>while</span> @@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 <span>for</span> a particular table name
end
这个SP将产生三列:
PHP经典实例(第2版)能够为您节省宝贵的Web开发时间。有了这些针对真实问题的解决方案放在手边,大多数编程难题都会迎刃而解。《PHP经典实例(第2版)》将PHP的特性与经典实例丛书的独特形式组合到一起,足以帮您成功地构建跨浏览器的Web应用程序。在这个修订版中,您可以更加方便地找到各种编程问题的解决方案,《PHP经典实例(第2版)》中内容涵盖了:表单处理;Session管理;数据库交互;使用We
453
1) db: 数据库名称
2) tab : 表名称
3) cdate: 表的创建时间
Ok, 上面的T-SQL不难懂,希望对您数据库开发有帮助。
您可能感兴趣的文章:
实用T-SQL之生成当前索引数据库中的外键上
几个有用的T-SQL(1)
作者:Petter Liu
出处:http://www.cnblogs.com/wintersun/
该文章也同时发布在我的独立博客中-Petter Liu Blog。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号