Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Pete_N
Posting Yak Master
181 Posts |
Posted - 2014-01-10 : 11:26:38
|
I am trying to create a trigger that fires after insert or update, but I only want the trigger to fire if certain fields are not null.Is there an easy way to do something like if SerialN and Brestlt And Boutcome <> Null from inserted ( Run Code ) |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-01-10 : 12:21:46
|
if exists (select * from inserted where serialn is not null and brestit is not null and boutcome is not null)...Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2014-01-10 : 14:03:02
|
depending on the code in your "Run Code" section:It it is possible that some of the rows in inserted will have non-null values for those columns but other will have null values - and I think it must be possible - then you should join to the inserted table in your "Run Code" statements and include the not null condition there.Be One with the OptimizerTG |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-01-10 : 23:56:16
|
also not null check should be as Tara showed and you should not be using <>,> etc with NULL as under default settings(ANSI NULL) NULL is considered not as a value but just represents condition lack of value.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|