Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Need help with creating trigger using instead of insert.

$
0
0

Hi all,

I am trying to create a trigger that can read the inserted Mail data from table1 and check if the Mail data matches the Mail data from table2. If the Mail data matches the Mail data from table2 it will get the EmpID from table2 and insert it into table1 column EmpID. 

Here are table2 columns:

EmpID (int)    Mail(varchar)      Mail2(varchar)

101            test1@test.com     test20@test.com

102            test2@test.com     test21@test.com

----------------

table1 columns 

EmpID (int)(primary key)   Mail(varchar)    Mail2(varchar)

----------------

If I insert test1@test.com into table1 column Mail, I would like it to get the value for the EmpID from table2 before actually inserting the record into table1, by matching the Mail from table1 = Mail from table2.

I am using ASP.Net to insert the records into Mail and Mail2.

How can I achieve that?

I appreciate any help.



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>