Enumerate databases

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ab

    Enumerate databases

    This shouldn't be too hard but I can't find the right answer: How can I
    enumerate all databases in my SQL Server (V7)?

  • Dan Guzman

    #2
    Re: Enumerate databases

    Try:

    SELECT name FROM sysdatabases

    I've also seen the INFORMATION_SCH EMA.SCHEMATA view (SQL 2000) used for this
    purpose but that should be avoided. That technique will break in SQL 2005
    because the vew behavior was changed to align with the ANSI standard.

    --
    Hope this helps.

    Dan Guzman
    SQL Server MVP

    "ab" <absmienk@hotma il.com> wrote in message
    news:1151316129 .417576.287020@ i40g2000cwc.goo glegroups.com.. .[color=blue]
    > This shouldn't be too hard but I can't find the right answer: How can I
    > enumerate all databases in my SQL Server (V7)?
    >[/color]


    Comment

    • ab

      #3
      Re: Enumerate databases

      Thanks Dan, that helped.



      Dan Guzman schreef:
      [color=blue]
      > Try:
      >
      > SELECT name FROM sysdatabases
      >
      > I've also seen the INFORMATION_SCH EMA.SCHEMATA view (SQL 2000) used for this
      > purpose but that should be avoided. That technique will break in SQL 2005
      > because the vew behavior was changed to align with the ANSI standard.
      >
      > --
      > Hope this helps.
      >
      > Dan Guzman
      > SQL Server MVP
      >
      > "ab" <absmienk@hotma il.com> wrote in message
      > news:1151316129 .417576.287020@ i40g2000cwc.goo glegroups.com.. .[color=green]
      > > This shouldn't be too hard but I can't find the right answer: How can I
      > > enumerate all databases in my SQL Server (V7)?
      > >[/color][/color]

      Comment

      • DickChristoph

        #4
        Re: Enumerate databases

        At some point they added

        sp_databases

        as a command that could be run. It works in SQL 2000 anyway.

        --
        -Dick Christoph

        "Dan Guzman" <guzmanda@nospa m-online.sbcgloba l.net> wrote in message
        news:rNPng.5361 2$fb2.23804@new ssvr27.news.pro digy.net...[color=blue]
        > Try:
        >
        > SELECT name FROM sysdatabases
        >
        > I've also seen the INFORMATION_SCH EMA.SCHEMATA view (SQL 2000) used for
        > this purpose but that should be avoided. That technique will break in SQL
        > 2005 because the vew behavior was changed to align with the ANSI standard.
        >
        > --
        > Hope this helps.
        >
        > Dan Guzman
        > SQL Server MVP
        >
        > "ab" <absmienk@hotma il.com> wrote in message
        > news:1151316129 .417576.287020@ i40g2000cwc.goo glegroups.com.. .[color=green]
        >> This shouldn't be too hard but I can't find the right answer: How can I
        >> enumerate all databases in my SQL Server (V7)?
        >>[/color]
        >
        >[/color]


        Comment

        Working...