I have two tables in differents databases : Master database :
ServerInformation 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'.
Im using the follow Trigger
CREATE TRIGGER UPDate_Documentos_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!Try this (untested):
CREATE TRIGGER UPDate_Documentos_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
--|||Leonardo Almeida (leonardoalmeida2004@.yahoo.com.br) writes:
> CREATE TRIGGER UPDate_Documentos_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'
You have swapped database name and ownername. Use Index2003..Documentos
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
http://www.microsoft.com/sql/techin.../2000/books.asp
No comments:
Post a Comment