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
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 How to write Trigger to insert duplicate record

Author  Topic 

srikanthkamuju
Starting Member

1 Post

Posted - 2010-01-08 : 06:32:16
Hi all,

I am new to sql server

my requirement is i have 2 table below the tables structure

1 emp 2 copy Emp

id ename salary id ename salary status


when ever a record is insereted into the emp table the same record should insert automatically into copy emp record

how to achieve this using triggers

tell me step by step because i am weak in sql

thanks in advance

srikanth

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-08 : 10:52:44
[code]
CREATE TRIGGER CopyEmpInsert
ON Emp
AFTER INSERT
AS
BEGIN
INSERT INTO CopyEmp
SELECT id,ename,salary,<your status value>
FROM INSERTED
END
[/code]
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-01-08 : 11:10:26
quote:
Originally posted by srikanthkamuju

Hi all,

I am new to sql server

my requirement is i have 2 table below the tables structure

1 emp 2 copy Emp

id ename salary id ename salary status


when ever a record is insereted into the emp table the same record should insert automatically into copy emp record

how to achieve this using triggers

tell me step by step because i am weak in sql

thanks in advance

srikanth



Read about Triggers in BOL. This is the very basic of triggers and you are better off if you read it and implement it yourself.

EDIT : This should be a start.
http://msdn.microsoft.com/en-us/library/ms189799.aspx
Go to Top of Page

debrah.h48
Starting Member

4 Posts

Posted - 2010-01-17 : 23:38:55
Hope this discussion forum will give you clear picture on this topic.
(spam removed)
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-01-18 : 00:43:33
quote:
Originally posted by debrah.h48

Hope this discussion forum will give you clear picture on this topic.
<SPAM LINK REMOVED>


There is nothing in your link that is relevant to the OP
Go to Top of Page
   

- Advertisement -