Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Trigger - Copy From/To After Update

Author  Topic 

sinjin67
Yak Posting Veteran

53 Posts

Posted - 2010-06-03 : 18:14:18
Not sure what I have done wrong, Hoping someone can point in right direction. I am trying to creat a trigger that update another table in a another table. Here is my basic script, I thought that if I wanted it to copy the data you need to remove the where clause.
Any help would be great..



USE [USERS]
GO
/****** Object: Trigger [dbo].[mycopy99] Script Date: 06/03/2010 15:03:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[mycopy99] ON [dbo].[users] AFTER UPDATE
as
begin
begin tran

SELECT * INTO USERS2.dbo.users
FROM USERS.dbo.users


commit tran
end

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-06-03 : 18:24:10
ALTER TRIGGER [dbo].[mycopy99] ON [dbo].[users] AFTER UPDATE
as
begin

INSERT INTO USERS2.dbo.users
SELECT * FROM inserted

end

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -