November 22, 2013 at 1:20 pm
This is the structure of the tables and the trigger that I am looking for
Sales(table) has Column key3
Users(table) has Columns UserID,UserName
Department(table) has column Account
When someone enters a UserName(table USERS) for key3(table SALES). I then want a trigger to be able to pick up that associated UserID(table USERS) and put this into Account (table DEPARTMENT).
So lets say a row in Users table had UserID: 87 UserName: Robin M
When someone enters Robin M into the key3 field
I would like her UserID inserted into the Account field.
Thank you very much for the help
November 22, 2013 at 1:30 pm
Have you tired creating a trigger and it isn't working or are you looking for someone to provide you a complete trigger? These forums are usually to help people with problems they are having and not providing complete works.
First off do you use stored procedures to insert the data into the Users table? If so, can you add your logic there instead of adding a trigger? I would recommend this approach to using a trigger if you can help it.
If it has to be done using a trigger (you will know this better than I) what are your specific questions about creating the trigger?
November 22, 2013 at 1:37 pm
also, this is aduplicate post.
no need to cross post to multiple forums it fractures the answers you get and makes posters duplicate others work.
the "Recent Posts" link shows us everything.
continue the thread here:
http://www.sqlservercentral.com/Forums/FindPost1516893.aspx
it's much better to provide the data the other posters asked for in the original thread than to start a new one.
Lowell
November 22, 2013 at 1:46 pm
Understood, since it was a trigger post I thought it should have been in here originally. I noticed that and thought I would get more feedback in this forum.
Sorry I am not looking for someone to complete it. I am really just looking for the trigger structure that I should have. I am new to triggers and have only dealt with fields within the same table. For example creating a trigger that would store the previous value in a field. I stored this value within the same table. I just don't know how you would correlate the USERNAME AND USERID in this case and have the trigger deal with the three tables.
I will work on it some more and provide an example of the trigger itself.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply