Philip
Philip

Reputation: 933

SQL Server dbo and schema

I've stumbled across some odd T-SQL code in SQL Server 2005, which I'm trying to understand how it could work.

If there are two tables called tblScenario in two separate schemas, one is in Cache schema and the other is in Dimension schema.

What would we expect to find when we query SELECT * FROM dbo.tblScenario? How does dbo map to one of these schemas in a reliable and predicable way?

For some reason this actually works however we don't know why?

We are going to fix it so it is explicitly calling SELECT * FROM Dimension.tblScenario, but I was curious.

Thanks,

Philip

Upvotes: 0

Views: 714

Answers (2)

dave
dave

Reputation: 1364

OLTP Check... 1) is DBO.tblScenario a view?

Othewise, it sounds like you're dealing with SQL Server Analysis Services (SSAS), which deals with dimensions, mimicing tables, etc. More info: http://technet.microsoft.com/en-us/library/cc966452.aspx

Upvotes: 1

user359040
user359040

Reputation:

If you are running the old version of the query in the Dimension schema I would expect it to return data from the Dimension schema, if you are running it in the Cache schema I would expect it to return data from the Cache schema, and if you are running it from any other schema I would expect it to return an error (similar to that recorded by Chris Diver).

Upvotes: 0

Related Questions