April 21, 2009 at 6:38 pm
Hello ,
I have this code:
IF EXISTS (select * from tempdb..sysobjects where id = object_id(N'[tempdb]..[#stats]'))
drop table #stats
GO
declare @stat float
declare @i int, @y int
declare @x float
create table #stats
(
[Database Name] nvarchar(20) ,
[Log size] float,
[Log Space Used] float,
[Status] int,
)
insert into #stats exec('dbcc sqlperf(logspace)')
set @y=(select count(*)[log size] from #stats)
set @i = 0
while @i<=@y
begin
set @x= select [Log size] from #stats
if @x >1.3
print 'check'
My purpose is to check log size of all databases, insert the results in a temp table named '#stats' and then reads the rows of temp table one by one and if the value is greater than 1.3 to print message 'check'.
I would appreciate if someone could help me.
Thanks,
john
April 21, 2009 at 6:50 pm
Can you just query the data that is bigger than 1.3 like the code below or are you trying to loop to perform some other logic?
IF EXISTS (select * from tempdb..sysobjects where id = object_id(N'[tempdb]..[#stats]'))
drop table #stats
GO
create table #stats
(
[Database Name] nvarchar(20) ,
[Log size] float,
[Log Space Used] float,
[Status] int,
)
insert into #stats exec('dbcc sqlperf(logspace)')
Select [Database Name] from #stats Where [Log size] > 1.3
April 22, 2009 at 3:41 pm
Thank you a lot. It is suitable for me.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply