Sybase database occupation
Sybase database occupation script
set nocount on declare @pgsize float --select @pgsize = (1048576. / v.low) from master.dbo.spt_values v where v.number = 1 and v.type = 'E' select @pgsize = 1048576 / @@maxpagesize select 'DbName' = substring(d.name, 1, 30), 'Usage' = convert(varchar(15),substring(m.description, 1, 14)), 'Size' = convert(varchar(13),right(space(13) + convert(varchar(10),convert(decimal(10,1), sum(u.size) / @pgsize)),10) + ' Mo'), --'Used' = convert(varchar(13),right(space(10) + convert(varchar(10),convert(numeric(10,1), 'Used' = convert(varchar(13),right(space(10) + convert(varchar(10),convert(decimal(10,1), sum(size - convert(float,curunreservedpgs(d.dbid,u.lstart, u.unreservedpgs))) / @pgsize)),10) + ' Mo'), 'Free' = convert(varchar(13),right(space(10) + convert(varchar(10),convert(numeric(10,1), sum( convert(float,curunreservedpgs(d.dbid, u.lstart, u.unreservedpgs))) / @pgsize)),10) + ' Mo'), --'PerUsed' = convert(varchar(8),right(space(6) + convert(varchar(6),convert(numeric(8,1), convert(money,sum(size - convert(float,curunreservedpgs(d.dbid,u.lstart, u.unreservedpgs)))) / convert(money, sum(size)) * 100.0)),6) + ' %') 'PerUsed' = convert(varchar(8),right(space(6) + convert(varchar(6),convert(decimal(8,1), convert(money,sum(size - convert(float,curunreservedpgs(d.dbid,u.lstart, u.unreservedpgs)))) / convert(money, sum(size)) * 100.0)),6) + ' %') from master.dbo.sysdatabases d, master.dbo.sysusages u, master.dbo.sysdevices v, master.dbo.spt_values a, master.dbo.spt_values b, master.dbo.sysmessages m where d.dbid = u.dbid and u.vdevno = v.vdevno --> nouveaute 15.0 --and v.low <= u.size + vstart --> ancien 12.5 --and v.high >= u.size + vstart - 1 --> ancien 12.5 --and v.status & 2 = 2 and a.type = 'E' and a.number = 1 and b.type = 'S' and u.segmap & 7 = b.number and b.msgnum = m.error and isnull(m.langid, 0) = 0 group by d.name, convert(varchar(30),m.description) order by d.name, convert(varchar(30),m.description)
Great information. Thanks for sharing.
ReplyDeleteSybase DBA Training Online