Friday, March 23, 2012

ist of Databases: do not use master.dbo.sysdatabases...

Is there a SP or view to list databases for a server (2000 & 2005)? SQL 2005
has a view for sysdatabases, but they say it will not be available after thi
s
version.
We have a SP that lists the security for Logins and Databases. It uses
master.dbo.sysdatabases to loop through the databases. We need to modify thi
s
so it is not using the master database tables.
Thanks and God Bless,
ThomBeauxThomBeaux,
The SQL 2005 sys.databases view does not exists on SQL 2000. However,
sp_helpdb works on both releases of SQL Server and is not on the deprecation
list.
If you need the results of sp_helpdb in a table for your processing, do:
CREATE TABLE #db
(name sysname,
db_size nvarchar(13),
owner sysname,
dbid smallint,
created datetime,
status nvarchar (600),
compatibility_level tinyint)
INSERT INTO #db EXEC sp_helpdb
SELECT * FROM #db
Then do what you need with the results.
RLF
"ThomBeaux" <ThomBeaux@.NoSpam.Com> wrote in message
news:7B6B13C5-C01B-43C6-A370-14B191A939D2@.microsoft.com...
> Is there a SP or view to list databases for a server (2000 & 2005)? SQL
> 2005
> has a view for sysdatabases, but they say it will not be available after
> this
> version.
> We have a SP that lists the security for Logins and Databases. It uses
> master.dbo.sysdatabases to loop through the databases. We need to modify
> this
> so it is not using the master database tables.
> --
> Thanks and God Bless,
> ThomBeaux|||Thanks...
--
Thanks and God Bless,
ThomBeaux
"Russell Fields" wrote:

> ThomBeaux,
> The SQL 2005 sys.databases view does not exists on SQL 2000. However,
> sp_helpdb works on both releases of SQL Server and is not on the deprecati
on
> list.
> If you need the results of sp_helpdb in a table for your processing, do:
> CREATE TABLE #db
> (name sysname,
> db_size nvarchar(13),
> owner sysname,
> dbid smallint,
> created datetime,
> status nvarchar (600),
> compatibility_level tinyint)
> INSERT INTO #db EXEC sp_helpdb
> SELECT * FROM #db
> Then do what you need with the results.
> RLF
> "ThomBeaux" <ThomBeaux@.NoSpam.Com> wrote in message
> news:7B6B13C5-C01B-43C6-A370-14B191A939D2@.microsoft.com...
>
>

No comments:

Post a Comment