Question
How can I edit values of an INSERT in a trigger on SQL Server?
I have the table Tb
ID | Name | Desc
-------------------------
1 | Sample | sample desc
I want to create a trigger on INSERT that will change the value of the inserting Desc
, for example:
INSERT INTO Tb(Name, Desc) VALUES ('x', 'y')
Will result in
ID | Name | Desc
-------------------------
1 | Sample | sample desc
2 | x | Y edited
In the above example I got the value of the inserting Desc
changed it to uppercase and added edited
on the end.
That's what I need, get the Desc
that is being inserted and modify it.
How can I do that?
Is it better to handle it after the insert with an update? Or make a trigger with INSTEAD OF INSERT and modify it everytime the table structure changes?