Reputation: 37
I have two tables, creds and users.
users
email password fullName contact city
creds
email password
I need a trigger which can copy email
and password
from users
into creds
upon insertion of new rows.
Upvotes: 2
Views: 117
Reputation: 28
Hope this following trigger works for you. More or less it will be like this
CREATE TRIGGER user_trigger
ON creds
FOR INSERT
AS
BEGIN
Insert into users(email, password, fullname, contact, city)
select distinct u.email, u.password
from inserteduser u
left join creds c
on u.email = c.email and u.password = c.password
END;
Upvotes: 1