Home Forums SQL Server 2008 T-SQL (SS2K8) Trying to bypass via tsql a database when it is offline RE: Trying to bypass via tsql a database when it is offline

  • Patti Johnson (9/4/2013)


    Thank you so much for your help. I've been digging and digging so I appreciate your time.

    IF DATABASEPROPERTYEX('archer', 'Status') = 'ONLINE'

    AND EXISTS(SELECT 1 FROM sys.database_mirroring WHERE database_id = DB_ID('archer') AND

    (mirroring_role IS NULL OR mirroring_role <> 2))

    BEGIN

    use archer

    SET NOCOUNT ON

    END

    Msg 954, Level 14, State 1, Line 6

    The database "Archer" cannot be opened. It is acting as a mirror database.

    Hmm, OK, let's ignore any db that is involved in mirroring then:

    IF DATABASEPROPERTYEX('archer', 'Status') = 'ONLINE'

    AND EXISTS(SELECT 1 FROM sys.database_mirroring WHERE database_id = DB_ID('archer') AND

    mirroring_role IS NULL)

    BEGIN

    use archer

    SET NOCOUNT ON

    END

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".