Monday, February 20, 2012

Master..sysdatabases.status column

Hi
sysdatabases.status column, is given some fixed values like:
WHEN status = 512 THEN 'offline'
WHEN status = 1024 THEN 'read only'
WHEN status = 2048 THEN 'dbo use only'and so on...
However when I put on the of the user databases in dbo use only, and I query
the
select * from master..sysdatabases
Then the value for status column for that database is not 2048, but it is
4112.
How do I interpret this code?
I am trying to write some job based on the status of the database.
Actually, that's a bitmask -- multiple bits can be on at the same time.
So it's really:
WHEN (status & 512) <> 0 THEN 'offline'
WHEN (status & 1024) <> 0 THEN 'read only'
... etc
Here is the complete list (cut from BOL):
1 = autoclose; set with ALTER DATABASE.
4 = select into/bulkcopy; set with ALTER DATABASE RECOVERY.
8 = trunc. log on chkpt; set with ALTER DATABASE RECOVERY.
16 = torn page detection, set with ALTER DATABASE.
32 = loading.
64 = pre recovery.
128 = recovering.
256 = not recovered.
512 = offline; set with ALTER DATABASE.
1024 = read only; set with ALTER DATABASE.
2048 = dbo use only; set with ALTER DATABASE RESTRICTED_USER.
4096 = single user; set with ALTER DATABASE.
32768 = emergency mode.
4194304 = autoshrink , set with ALTER DATABASE.
1073741824 = cleanly shutdown.
4112 = 4096 + 16 = torn page detection and single user ... not dbo use only
according to this?
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
"Pari" <Pari@.discussions.microsoft.com> wrote in message
news:C8D00A32-ADE7-4601-8297-648801AB1727@.microsoft.com...
> Hi
> sysdatabases.status column, is given some fixed values like:
> WHEN status = 512 THEN 'offline'
> WHEN status = 1024 THEN 'read only'
> WHEN status = 2048 THEN 'dbo use only' and so on...
> However when I put on the of the user databases in dbo use only, and I
query
> the
> select * from master..sysdatabases
> Then the value for status column for that database is not 2048, but it is
> 4112.
> How do I interpret this code?
> I am trying to write some job based on the status of the database.
>
>

No comments:

Post a Comment