jcb (11/19/2013)
Question: a select count(1) from inserted ill return the number of inserted rows?just for the record: avoid triggers, they are evil.
avoid to put business logic in the database, let the application to handle it in the appropriate layer.
I agree about triggers but as the OP stated this is a 3rd party app.
I am working with a commercial package so I have to be a little careful.
To be honest if I were going to use a trigger for this type of thing...which I would most certainly not I would totally rewrite this things.
This entire trigger looks to me to be a replacement for a foreign key. Basically the logic here is to not allow a value of LastPriceUOMKey that doesn't already exist in tciUnitMeasure. And don't get me started on NOLOCK...
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/