Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

weird error (database not activate or in transition)

Status
Not open for further replies.

rravenn

Programmer
Jul 6, 2004
40
US
Here's a query that is part of some complex query with unions.

Code:
            SELECT Email,'Mng' as Role
            FROM resManager
                INNER JOIN d10task.dbo.UserGroups ug ON resManager.GroupID = ug.GroupID
                INNER JOIN resRequestResource ON resRequestResource.RequestID = @RequestID
                INNEr JOIN resResource ON resRequestResource.ResourceID = resResource.ResourceID [highlight]/*here*/[/highlight]
                INNER JOIN D10Task.dbo.Users Users ON ug.UserID = Users.UserID
            WHERE resManager.ActionID = 1 [highlight]AND (resResource.CatID = resManager.CatID
                    OR  (Inherit = 1 AND dbo.resCatIsDescendant(resManager.CatId,resResource.CatID) = 1))[/highlight]

It works normally the way it is written; however, when I move the highlighted code to join (highlighted place), I start getting the error about Dtabase id 112 being wrong cause it's not activated or is in transition.

Why is that?
 
resCatIsDescendant() is an UDF?

That's likely the cause of a problem...

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Yeah, it is. WHy is that the source of the problem tho?
 
Check KB834688 article from M$DN.

Btw. if UDF performs some SELECTs on DB tables performance will suffer in both cases (JOIN and WHERE).

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
There's no other choice with ierarchical permsision. Well I could employ a lot of triggers to replicate them down the hierarchy and monitor it's changes but it just doesn't seem right.

Anyway, what's the actual problem with the error? :)
 
> There's no other choice with ierarchical permsision.

Well, not exactly... but that's another question if/when performance becomes unacceptable, right?

> Anyway, what's the actual problem with the error? :)

Purely internal thing... server/optimizer goes [spineyes]. With any of 3 conditions described in that KB article not present in a query, there are no problems. In your case join with UDF works after being written old-fashioned way (in WHERE clause).

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top