Trigger for insert table

Posted by shanks on Stack Overflow See other posts from Stack Overflow or by shanks
Published on 2010-04-30T14:47:47Z Indexed on 2010/04/30 14:57 UTC
Read the original article Hit count: 275

Filed under:
|

I have sql server 2005 and need to create trigger for insert query.

I have Table naemd as "Log" with column named as UserID,UserName,LogDate,LogTime and want to transfer data into other table named as "DataTable" with same column name.

I have created trigger

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TRIGGER [dbo].[Transfer] on [dbo].[Log]
AFTER INSERT
AS
BEGIN

insert into DataTable (UserID,UserName,LogDate,LogTime)

SELECT UserID,UserName,LogDate,LogTime 
FROM Log where UserID not in(select UserID from DataTable)

END

New Data is updated on daily basis in "Log" table and so i want to transfer new data from Log table to DataTable with trigger.Execution time is very high and so no output .

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about triggers