2

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.

shashankj
  • 37
  • 1
  • 11

1 Answers1

1

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;
Hussain
  • 5,057
  • 6
  • 45
  • 71