November 23, 2010 at 2:26 pm
I want to add a block of code that checks log file fullness before going on to the next index. Instead of having a Use Database command in the middle of the stored procedure I had hoped to stay in the master database context but explicitly pull from my database's sysfiles table/view.
The script below will give an accurate percentage of log file fullness if I change to mydatabase, but not if I stay in master and specify mydatabase.
from mydatabase.dbo.sysfiles where isnull(filegroup_name(groupid),'log')='log'
use mydatabase
go
declare @logpercentFree int
select @logpercentFree=
cast(100*(size/128-(FILEPROPERTY(name,'spaceused')/128))/(size/128.0)
as int)
from sysfiles where isnull(filegroup_name(groupid),'log')='log'
select @logpercentfree
November 24, 2010 at 1:00 am
Sample sql
USE TEMPDB
GO
select * from msdb.dbo.sysfiles
select * from master.dbo.sysfiles
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply