Invalid object name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leonardo Almeida

    Invalid object name

    Hi,

    I have two tables in differents databases : Master database :
    ServerInformati on where there is a table called "Clientes" and Table
    "Documentos " in the Database Index2003

    What I need to do via Trigger is update the table "Documentos " in the
    field "Cliente" everytime the "Clientes" table change the field
    'Cliente'.

    I´m using the follow Trigger

    CREATE TRIGGER UPDate_Document os_Index2003 ON dbo.Clientes
    FOR UPDATE
    AS

    UPDATE [dbo].[Index2003].[Documentos]
    SET [dbo].[Index2003].[Documentos].Cliente = i.Cliente
    FROM Inserted i
    INNER JOIN [dbo].[Index2003].[Documentos] D
    ON D.ID_Clientes = i.ID_Clientes


    When I commit the change in the register "Clientes" arise the follow
    message :

    Invalid object name 'dbo.Index2003. Documentos'

    Have I doing something wrong ?

    Thanks for attetion

    Leonardo Almeida

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • David Portas

    #2
    Re: Invalid object name

    Try this (untested):

    CREATE TRIGGER UPDate_Document os_Index2003 ON dbo.Clientes FOR UPDATE
    AS

    UPDATE [Index2003].[dbo].[Documentos]
    SET Cliente =
    (SELECT Cliente
    FROM inserted
    WHERE ID_Clientes =
    [Index2003].[dbo].[Documentos].ID_Clientes)
    WHERE ID_Clientes
    IN (SELECT ID_Clientes FROM inserted)

    --
    David Portas
    ------------
    Please reply only to the newsgroup
    --


    Comment

    • Erland Sommarskog

      #3
      Re: Invalid object name

      Leonardo Almeida (leonardoalmeid a2004@yahoo.com .br) writes:[color=blue]
      > CREATE TRIGGER UPDate_Document os_Index2003 ON dbo.Clientes
      > FOR UPDATE
      > AS
      >
      > UPDATE [dbo].[Index2003].[Documentos]
      > SET [dbo].[Index2003].[Documentos].Cliente = i.Cliente
      > FROM Inserted i
      > INNER JOIN [dbo].[Index2003].[Documentos] D
      > ON D.ID_Clientes = i.ID_Clientes
      >
      >
      > When I commit the change in the register "Clientes" arise the follow
      > message :
      >
      > Invalid object name 'dbo.Index2003. Documentos'[/color]

      You have swapped database name and ownername. Use Index2003..Docu mentos
      instead.

      Also, in the left-hand side of the SET-clause, you should use any
      prefix at all.

      --
      Erland Sommarskog, SQL Server MVP, sommar@algonet. se

      Books Online for SQL Server SP3 at
      SQL Server 2025 redefines what's possible for enterprise data. With developer-first features and integration with analytics and AI models, SQL Server 2025 accelerates AI innovation using the data you already have.

      Comment

      Working...