Thank you Hilary.
"Hilary Cotter" <hilary.cotter@gmail.com> wrote in message
news:Om8G9RytHHA.1212@TK2MSFTNGP05.phx.gbl...
> For a database to be online in SQL Server 2005, it really means the
> primary database file(s) is/are online.
>
> You would have to query all database files to check their availabilty to
> ensure that the entire database is online. Here is an example.
>
> create database offlinefiles
>
> go
>
> use offlinefiles
>
> go
>
> ALTER DATABASE offlinefiles ADD FILEGroup test
>
> GO
>
> ALTER DATABASE offlinefiles ADD FILE ( NAME = 'test', FILENAME =
> 'C:\test.ndf' )
>
> TO FILEGROUP [test]
>
> GO
>
> SELECT NAME, PHYSICAL_NAME, is_read_only, state_desc , name
>
> FROM sys.database_files WHERE STATE_DESC<>'ONLINE'
>
> go
>
> ALTER DATABASE offlinefiles MODIFY FILE (NAME = test, OFFLINE )
>
> GO
>
> SELECT NAME, PHYSICAL_NAME, is_read_only, state_desc , name
>
> FROM sys.database_files WHERE STATE_DESC<>'ONLINE'
>
>
>
>
>
> --
> Looking for a SQL Server replication book?
>
http://www.nwsu.com/0974973602.html >
> Looking for a FAQ on Indexing Services/SQL FTS
>
http://www.indexserverfaq.com > "NewToSql" <NoOne@hotmail.com> wrote in message
> news:Odt9jqqtHHA.3356@TK2MSFTNGP03.phx.gbl...
>> Hi,
>> a database could have its Sys.Databases(State) = Online, yet, you may
>> not be able to access it.
>> for example, if you run : Use databaseName. you may get an error message
>> such as the database file is not accessible.
>> The question, is how to determine if a database is not only online but
>> also "ready, accessible, and usable" that is you can access it, and run
>> queries...? Is such info available in any system views?
>> Thanks
>>
>>
>
>