SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Quickly Viewing Available Space

By Boris Baliner, 2006/06/06

Total article views: 8539 | Views in the last 30 days: 54

View Available Space in SQL Server 2000 databases using SQL Server 2005 Management Studio.

Introduction

In March I wrote an article entitled “SQL 2000 to SQL 2005: Where have all the old features gone?”, that dealt with accessing SQL Server 2000 with SQL 2005 tools. Initial idea was that many DBAs are probably using such setup to get accustomed to the new tools, although their employer has not made the move to the SQL Server 2005 yet.

In March article I forgot to mention what I now consider to be an important addendum: how to quickly view Available Space in the files of any given database.

Taskpad functionality

Basically we want to be able to see the free space left in database files, and if you are not connecting to SQL Server 2005 you are not enjoying the latest/greatest colorful Reports in the Summary tab. Oh No, life is worthless, you say…but wait, don’t jump off the cliff yet, because here comes the solution. Simply run the following code in the context of your database:

CREATE PROCEDURE dbo.usp_ShowAvailableSpace 
AS

SELECT name AS NameOfFile,
  size/128.0 -CAST(FILEPROPERTY(name, 'SpaceUsed' )AS int)/128.0 AS AvailableSpaceInMB
 FROM dbo.SYSFILES
GO

Then execute:

EXEC usp_ShowAvailableSpace

You should get something like this:

If you track what Taskpad does, it does precisely that, except that it rounds it off to the hundredth of a megabyte. If you really what the same functionality as Taskpad, just run the following code:

Summary

This is a quick little tool get back what Taskpad offers to Enterprise Manager users. So, until you convert all your servers to SQL 2005 this may prove helpful, hopefully.

By Boris Baliner, 2006/06/06

Total article views: 8539 | Views in the last 30 days: 54
Your response
 
 
Related tags
 
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com