Getting details about all SQL databases with one query

by rahul 11/11/2008 6:11:39 AM

Scenario: You have a SQL Server, and plenty of databases. Time progresses, and you started using another Disk OR Partition. Let's say you want to know how much space is being taken by all the Databases put together. OR better still, you want to get the details of all the Databases at one shot and not via that Right-Click->Properties thingy...

Here is what could help you...


    Go to SQL Query Analyzer window and ensure that Results to Text (CTRL + T) option is selected.

          image 
            
    Type the following in Query window and Execute it...
            select 'sp_helpdb ''' + name + '''' + char(10) + 'go'  from sys.databases

    Here is how my output looks like...
            image
    Copy the selected part as shown above and execute, and you should get the details about all the tables at one shot. Yeah, this is no rocket science, but quite effective at times. Thumbs-up

Cheers, Smile
Rahul


Quote of the day:
An ignorant person is one who doesn't know what you have just found out. - Will Rogers


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Tips and Tricks | SQL

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Calendar

<<  January 2009  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway. We try our best to write good code, but none of the code here is tested on Production boxes. Feel free to use the code, BUT test it before you do so (in simple words... use it at your own risk)

© Copyright 2009

Sign in