Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

SQL trigger Expand / Collapse
Author
Message
Posted Tuesday, December 17, 2013 2:04 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 1:06 PM
Points: 35,371, Visits: 31,917
wat3575 (11/22/2013)
We are using a CRM system and I have had trouble creating a trigger that would automatically update another field on a record. The first table I am working with is Sales that has a key3 field. Within this field we insert Sales Rep names from a user table. Within this users table we have another column with the users ID. So what I would like to do is create a trigger that would recognize when a Sales Rep name is added to this key3 field and then autoupdate another field with the associated USERID. Thank you for the help.


I'm going to recommend NOT using a trigger to do this.
I'm also going to recommend NOT using a stored procedure to do this.

In fact, I'm going to recommend NOT doing this at all.

It's a form of denormalization AND unnecessary duplication of data. Further, if there's ever a name change for the given ID, you'll need a separate one-off process to change it. Even if that never happens, it's still an unnecessary duplication of data and should be avoided because of all of the rules of normalization.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1523883
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse