469,902 Members | 1,813 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

Trigger to update table.

parshupooja
159 100+
Hey All

I have table Employee which has coluumns (id, name, address, ssn, DOB, date of join,level etc )employee records. Everytime there is new employee in company, there is new entry in Employee table.
I have another table User which has three columns (id, user, password) which consists name of all current employee in user column and ther password is name+123.

I want to write a trigger which automatically should update the User table with name, name +123 of new user when new employee is added to Employee table.

Do help,
Thanks
Nov 29 '07 #1
5 1507
debasisdas
8,127 Expert 4TB
Kindly post what you have tried so far.
Nov 29 '07 #2
parshupooja
159 100+
I haven't wriiten anything since I don't know much abt Triggers

Kindly post what you have tried so far.
Nov 29 '07 #3
This is the trigger

CREATE TRIGGER your_trigger_name
ON Employee
FOR INSERT AS
BEGIN

INSERT User (Name,Password)
SELECT Name, Name + '123' FROM INSERTED
END

Substitute the column names if they are different in your table, Because there are some reserved words in these names

Krishnaraj
Dec 2 '07 #4
parshupooja
159 100+
Thanksssssssssssssssssss


This is the trigger

CREATE TRIGGER your_trigger_name
ON Employee
FOR INSERT AS
BEGIN

INSERT User (Name,Password)
SELECT Name, Name + '123' FROM INSERTED
END

Substitute the column names if they are different in your table, Because there are some reserved words in these names

Krishnaraj
Feb 11 '08 #5
ck9663
2,878 Expert 2GB
here's more about trigger

-- ck
Feb 11 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Trevor Fairchild | last post: by
9 posts views Thread by Martin | last post: by
33 posts views Thread by coosa | last post: by
18 posts views Thread by Bill Smith | last post: by
reply views Thread by JohnO | last post: by
2 posts views Thread by Net Virtual Mailing Lists | last post: by
2 posts views Thread by mob1012 via DBMonster.com | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.