From: Rick on
Still using SQL 2000.

In the examples for ALTER DATBASE in the SQL Books Online they always
execute a USE MASTER before the ALTER DATABASE [dbname]... statement.
Why do they do this?

Also: is there a way to use ALTER DATABASE to just *view* various db
options, the way I previously used sp_dboption?

Thanks for any help.
From: Erland Sommarskog on
Rick (rick0726(a)verizon.net) writes:
> Still using SQL 2000.
>
> In the examples for ALTER DATBASE in the SQL Books Online they always
> execute a USE MASTER before the ALTER DATABASE [dbname]... statement.
> Why do they do this?

I don't think there is any particular reason. Maybe just some good idea
of "best practice". There are some commands that require you to be in
master, for instance grant of server-level permissions in SQL 2005. But
ALTER DATABASE is not one of them.

> Also: is there a way to use ALTER DATABASE to just *view* various db
> options, the way I previously used sp_dboption?

Nope.


--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx