Triggers in sql server 2005

pts.
Tags:
SQL Server
SQL Server 2005
hi Experts, I have created a table called MyEmployees with ManagerID,ContactID,etc.,.. fields. Also i created another table ManagerAndContact with Only ManagerID and ContactID as fields. Now what i need is, whenever am inserting a new row in MyEmployees table, the corresponding ManagerId and ContactId should be inserted into the second table - ManagerAndContact using trigger. Note: the id's are not in ascending or descending order. The data to the MyEmployees are fetched from a text file with random values for id's(managerid,contactid) Ex: 1029, 1019, 1044, 1024. ......

Answer Wiki

Thanks. We'll let you know when a new response is added.

Yes. You can do this using the insert trigger. Select the values from the inserted table that is available in the insert trigger and insert them in the ManageAndContact table.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Denny Cherry
    I would have to ask, what is the second table used for? It appears to be a duplicate of the columns in the MyEmployees table. I would say that a database design review needs to be done to make sure that this actually needs to be done this way, and most probably remove the duplicate table.
    66,010 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following