I can’t figure out what state my database is in. Sysdatabases shows me status values that don’t exist in books online like 532.
First, let’s dispense with the standard answer, “If you upgrade to SQL Server 2005 (or if you already have) the new system management and catalog views will provide you with more useful information.” While this is a stock answer, it happens to be very true in this particular scenario.
sysdatabases is the SQL Server 2000 catalog view whose status column displays:
1 = autoclose (ALTER DATABASE)
4 = select into/bulkcopy (ALTER DATABASE using SET RECOVERY)
8 = trunc. log on chkpt (ALTER DATABASE using SET RECOVERY)
16 = torn page detection (ALTER DATABASE)
32 = loading
64 = pre recovery
128 = recovering
256 = not recovered
512 = offline (ALTER DATABASE)
1024 = read only (ALTER DATABASE)
2048 = dbo use only (ALTER DATABASE using SET RESTRICTED_USER)
4096 = single user (ALTER DATABASE)
32768 = emergency mode
4194304 = autoshrink (ALTER DATABASE)
1073741824 = cleanly shutdown
Multiple bits can be ON at the same time.
The last sentence about the multiple bits is what’s getting you. In your case, a database showing a status of 532 is set to allow select into/bulkcopy (BULK_LOGGED recovery), to enable torn page detection and is currently offline (4 + 16 + 512 = 532).
sys.databases is the SQL Server 2005 catalog view and offers more insight (while requiring you to query more columns, which is fair in my opinion). Using this view you’ll find columns identifying statuses and configuration options both numerically and using descriptions. So, using your status of 532 again, but by querying sys.databases, you’ll see:
[recovery_model]=2,
[recovery_model_desc]=’BULK_LOGGED’,
[page_verify_option]=1,
[page_verify_option_desc]=’TORN_PAGE_DETECTION’,
[state]=6,
[state_desc]=’OFFLINE’
Hope that helps.