Chinaunix首页 | 论坛 | 博客
  • 博客访问: 208346
  • 博文数量: 28
  • 博客积分: 128
  • 博客等级: 民兵
  • 技术积分: 400
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-19 13:05
个人简介

生活的内容不全是工作,工作只是生活的一部分;享受生活,热爱工作!

文章分类
文章存档

2015年(1)

2014年(23)

2011年(4)

分类: Sybase

2014-08-29 16:30:10

给大家Share 一个获取数据库内表大小的存储过程,希望大家有用到,注意一下username改成应用的用户名。
create procedure sp_gettablesize
as
begin
    declare @tablename char(100)
    declare tabname_cur cursor for select Table_owner+'.'+table_name from sp_iqtable() where table_type='BASE' and server_type='IQ' and Table_owner='username'
    create table #tablesize_temp(
      tablename char(100) null,
      kbytes integer
    )
    open tabname_cur
    fetch tabname_cur into @tablename
    while(@@sqlstatus = 0)
    begin
        fetch tabname_cur into @tablename
        insert into #tablesize_temp select tablename,convert(integer,kbytes) as kbytes from sp_iqtablesize(@tablename)
    end
    close tabname_cur
    deallocate cursor tabname_cur
    select top 100 tablename,kbytes from #tablesize_temp order by kbytes desc
end


阅读(2773) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~