Schema's referencing objects with the same name.

  • CREATE SCHEMA A1 AUTHORIZATION [dbo]

    CREATE SCHEMA A2 AUTHORIZATION [dbo]

    SELECT * FROM A1.Invoices

    INNER JOIN A2.Invoices

    ON A1.Invoices.OrderID = A2.Invoices.OrderID

    SQL server is throwing me an issue with the The objects "A1.Invoices" and "A2.Invoices" in the FROM clause have the same exposed names. Use correlation names to distinguish them.

    It clearly is a aliasing issue; However wasn't the Schema name should have handled it and avoided me to create an alias? I mean doesnt this break the idea of schema's when sql server feels that they are still the same objects. I was kind of puzzled to see this type of error thrown, especially with Schemas in place. Maybe i never came across it before.

    and if a user had access to both A1 and A2 schema's he should have been able to access both the objects in the same query without using alias was my idea of schema's.

  • Provided that you have the same table name created in both schemas I would view this as a defect and log it in Connect or at least look there to see if there is one already..

    CEWII

  • These are actually views rather objects; which should not make any difference in the query execution as such. And since I have an access to the schema's should have been able to query it without the need of alias.

    Unless I am missing here something.

  • I would tend to agree, it feels like a defect. I'd check Connect and see whats there..

    CEWII

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply