June 30, 2002 at 10:42 am
Hi Friends,
I have a status table which contains total number of records from another table in category wise. The table contains 1 integer and 13 tinyinteger datatype. The values in the last 13 fields are updating according to the updation in another table. I create a trigger and it works fine. Now the problem is that I don't want to store value 0 in my status table. ie when the value change to 0, it should automatically change into null. Can anyone help me write a trigger in my status table to do so.
Like we can find out recently updated or deleted rows through inserted/deleted table how can we find our updated row. From the BOL I find something like IF COLUMNS_UPDATED() & columnnumber). Should I use something like this.
Pls let me know
Thanks in advance
Cheers
Manoj
P.B. No 14337
Doha - Qatar
Ph: 4435361
web:www.fccqatar.com
P.B. No 14337
Doha - Qatar
Ph: 4435361
web:www.fccqatar.com
June 30, 2002 at 11:36 am
You can just run an update inside your trigger that looks something like this:
update colname=null where pkey in (select pkey from inserted where colname=0)
I dont know that the conditional update() is needed since if colname=0, you always change to null, right?
If you have SQL2K, you could use an insert trigger that changes the insert to something like this:
insert into table blahblah (colname)
select nullif(colname,0) from inserted
Andy
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply