Tuesday, February 21, 2012

Returning log File space sued

I am writing a database space tracking setup. I can get
data file space figures eventually (with my variant of
sp_spaceused), but finding the log file space used - such
as DBCC SQLPERF(LOGSPACE) shows, and also Enterprise
Manager, how do I get that preferably with some simple SQL
query ?
TIA
Jim
CREATE TABLE Test
(
[Database Name] VARCHAR(50),
[Log Size] REAL,
[Log Space Used] REAL,
Status TINYINT
)
INSERT INTO Test EXEC ('DBCC SQLPERF(LOGSPACE)')
GO
SELECT * FROM Test WHERE .........
GO
Drop table Test
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message
news:1f5c01c44874$e1165580$3a01280a@.phx.gbl...
> I am writing a database space tracking setup. I can get
> data file space figures eventually (with my variant of
> sp_spaceused), but finding the log file space used - such
> as DBCC SQLPERF(LOGSPACE) shows, and also Enterprise
> Manager, how do I get that preferably with some simple SQL
> query ?
> TIA
|||Hi,
Try the below query, This query will work even if we have multiple
transaction log files.
select sum(maxsize * 8.0/1024.0) AS MAX_SIZE ,sum(size * 8.0/1024.0) AS
CURRENT_SIZE
from sysfiles a where groupid = 0
Thanks
Hari
MCDBA
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message
news:1f5c01c44874$e1165580$3a01280a@.phx.gbl...
> I am writing a database space tracking setup. I can get
> data file space figures eventually (with my variant of
> sp_spaceused), but finding the log file space used - such
> as DBCC SQLPERF(LOGSPACE) shows, and also Enterprise
> Manager, how do I get that preferably with some simple SQL
> query ?
> TIA
|||The query "insert into <table> exec ('dbcc sqlperf (logspace ' )"
worked a treat !
This one
select sum(maxsize * 8.0/1024.0) AS MAX_SIZE ,sum(size * 8.0/1024.0) AS
CURRENT_SIZE
from sysfiles a where groupid = 0
didn't because maxsize is set to unlimited.
Thanks for your answers !
Jim Trowbridge
DBA
jtrowbridge@.adelaidebank.com.au
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!

No comments:

Post a Comment