Tuesday, March 27, 2012

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)?Try:

SELECT name FROM sysdatabases

I've also seen the INFORMATION_SCHEMA.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@.hotmail.com> wrote in message
news:1151316129.417576.287020@.i40g2000cwc.googlegr oups.com...
> 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)?|||Thanks Dan, that helped.

Dan Guzman schreef:

> Try:
> SELECT name FROM sysdatabases
> I've also seen the INFORMATION_SCHEMA.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@.hotmail.com> wrote in message
> news:1151316129.417576.287020@.i40g2000cwc.googlegr oups.com...
> > 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)?|||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@.nospam-online.sbcglobal.net> wrote in message
news:rNPng.53612$fb2.23804@.newssvr27.news.prodigy. net...
> Try:
> SELECT name FROM sysdatabases
> I've also seen the INFORMATION_SCHEMA.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@.hotmail.com> wrote in message
> news:1151316129.417576.287020@.i40g2000cwc.googlegr oups.com...
>> 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)?
>>sql

No comments:

Post a Comment