July 1, 2008 at 11:14 pm
Hi All,
In Trigger, now i am using update command.
I want to use column_updated for my scenario..
CREATE TRIGGER Test_IU_2 ON Test_T FOR UPDATE
AS
IF EXISTS(SELECT 1 FROM INSERTED)
BEGIN
IF UPDATE (ID)
BEGIN
INSERT INTO Test_T (table_name,action,user,datetime)
SELECT 'Test_t', 'UPDT',SUSER_SNAME(),getdate() FROM inserted i
END
END
Instead of update i want to use column_updated.
Can u help me how can i use column_updated
July 2, 2008 at 2:30 am
If you want to check whether the first column has been updated, then use:
IF (COLUMNS_UPDATED() & 1 ) > 0
Edit: sorry, I copypasted the wrong line 🙁
Regards,
Andras
July 2, 2008 at 7:12 am
Books Online has details on how to check which columns were updated using Columns_Updated. The key is understanding the bitwise operator, which is also linked to in Books Online in the article on Columns_Updated.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
July 3, 2008 at 5:17 am
Thank you Very Much Andras Belokosztolszki.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply