#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    50
    Rep Power
    15

    How to query the database list


    Hi! is there's a statement that will return the list of database in MS SQL? Thanks.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,782
    Rep Power
    4301
    select * from master..sysdatabases
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    list of database in MS SQL


    Originally Posted by naph
    Hi! is there's a statement that will return the list of database in MS SQL? Thanks.
    In SQL server 2005, you can use
    SELECT * FROM SYS.DATABASES


    IN SQL SERVER 2000, YOU HAVE TO QUERY THE SYSOBJECTS TABLE.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,803
    Rep Power
    352
    In all versions you should be able to simply use the stored procedure sp_databases

    http://msdn.microsoft.com/en-us/library/aa259636(SQL.80).aspx
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0
    How to list all the tables in a database?..
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,803
    Rep Power
    352
    Seems you are too lazy to have a look at the manual:

    http://msdn.microsoft.com/en-us/library/aa259564(SQL.80).aspx

IMN logo majestic logo threadwatch logo seochat tools logo