So, you find out one of the database server had log drive almost full. Basically one of the database log file has grown big. But you have multiple databases on the server and you don't know which one!
So you just go to the log file folder and sort the files with size. Sure ! That would work, but I will have to Remote Desktop to the server. And I don't like to do that. Besides it doesn't really tell me if that's really all the log files for the database and so forth. Point is I want to write this blog and tell you a nice way to get the results of DBCC SQLPerf(logspace) sorted by size. There you're !!!
CREATE TABLE #LogSpace (cap_date Datetime default getdate(),
db sysname,
log_size float,
space_used float,
status bit)
Insert #LogSpace (db, log_size, space_used, status) exec ('dbcc sqlperf (logspace)')
SELECT * FROM #LogSpace order by log_size desc
And that's the end of that story.
So you just go to the log file folder and sort the files with size. Sure ! That would work, but I will have to Remote Desktop to the server. And I don't like to do that. Besides it doesn't really tell me if that's really all the log files for the database and so forth. Point is I want to write this blog and tell you a nice way to get the results of DBCC SQLPerf(logspace) sorted by size. There you're !!!
CREATE TABLE #LogSpace (cap_date Datetime default getdate(),
db sysname,
log_size float,
space_used float,
status bit)
Insert #LogSpace (db, log_size, space_used, status) exec ('dbcc sqlperf (logspace)')
SELECT * FROM #LogSpace order by log_size desc
And that's the end of that story.
Thanks great article, there i found a article discussing about workings of DBCC Log commands. you may also check this here:
ReplyDeletehttp://www.sqlmvp.org/dbcc-log-command-in-sql-server/
Very good!!! thanks!
ReplyDelete