Problem creating indexed views with linked servers

  • Hi, I have a problem, maybe someone can help me.

    I'm traing to create a view with a Linked Server

    This query works great:

    select id, descr

    from SERVER.DB.dbo.TABLE

    When I tray to create the view:

    CREATE VIEW dbo.View1 WITH SCHEMABINDING

    AS

    select id, descr

    from SERVER.DB.dbo.TABLE

    GO

    I have this error:

    Server: Msg 4512, Level 16, State 3, Procedure Pais2, Line 3

    Cannot schema bind view 'dbo.View1' because name 'SERVER.DB.dbo.TABLE' is invalid for schema binding. Names must be in two-part format and an object cannot reference itself.

    So I try this:

    CREATE VIEW dbo.View1 WITH SCHEMABINDING

    AS

    select SERVER.DB.dbo.TABLE.id, SERVER.DB.dbo.TABLE.descr

    from SERVER.DB.dbo.TABLE

    GO

    I have this error:

    Server: Msg 117, Level 15, State 2, Procedure Pais2, Line 3

    The number name 'SERVER.DB.dbo.TABLE' contains more than the maximum number of prefixes. The maximum is 3.

    Then I try this:

    CREATE VIEW dbo.View1 WITH SCHEMABINDING

    AS

    select a.id, a.descr

    from SERVER.DB.dbo.TABLE as A

    GO

    I Have this error

    Server: Msg 4512, Level 16, State 3, Procedure View1, Line 3

    Cannot schema bind view 'dbo.View1' because name 'iservsql1.osderrhh.dbo.pais' is invalid for schema binding. Names must be in two-part format and an object cannot reference itself.

    This query alone works great:

    select a.id, a.descr

    from SERVER.DB.dbo.TABLE as A

    The names aren't what I describe here (id is not valid without []).

    ANY IDEAS?!??!?!

    I don't know what else can I do.

    I need help!!!

    TANKS A LOT!!!!!!!!

  • What you are trying to do will not work.  SQL Server does not provide for any type of declared constraint across databases including schemabinding.

    /*****************

    If most people are not willing to see the difficulty, this is mainly because, consciously or unconsciously, they assume that it will be they who will settle these questions for the others, and because they are convinced of their own capacity to do this. -Friedrich August von Hayek

    *****************/

  • Tanks for the quick answer!

    I'm gona try something else.

    There is some way to "cache" the data of a view??

    Tanks!!!

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

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