July 27, 2010 at 4:36 am
Hi!
I'm trying to make a trigger that is triggered when updating a field.
In this case I need information of all the columns when information of any column
is edited.
e.g.
I edit the column4 field from value 1 to 10 the trigger makes changes to the
edit column adding all the unedited information into the edit column in a single line from the
column1, column2 etc. columns separated with commas.
[column1] [char](11) NOT NULL, <--primary key
[column2] [char](1) NULL,
[column3] [char](1) NULL,
[column4] [char](2) NULL,
[column5] [char](1) NULL,
[edit] [varchar](100) NOT NULL
Is this even possible?
=)
July 27, 2010 at 5:41 am
well, it's pretty straight forward to do in a trigger, but i would just make the [edit] column a calculated field instead and get rid of the trigger idea altogether.
UPDATE sometable
SET [edit] = [column1] + ',' + [column2] --etc
FROM INSERTED
WHERE sometable.[column1] = INSERTED.[column1]
but the calculated field would simply be:
ALTER TABLE sometable ADD [edit] AS [column1] + ',' + [column2] --etc
Lowell
July 27, 2010 at 5:46 am
Thank you
Gonna try those and see if it suits for these
people over here =)
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply