Hi. Can anybody tell me how can I update a column of a record when it is inserted to the database. Here's the pseudocode that I want.
if( mytable.OriginalId == null )
mytable.OriginalId = Scope_Identity();
Hi. Can anybody tell me how can I update a column of a record when it is inserted to the database. Here's the pseudocode that I want.
if( mytable.OriginalId == null )
mytable.OriginalId = Scope_Identity();
This would be contradictory I think. Either OriginalId is set or it isn't on insert.
If it isn't where does Scope_Identity()
get it's value from? If it's from another column then would it not be better to use a computed column?
Sorry, it's not clear what the overall objective is... you would not normally use a trigger especially if OriginalId is part of the PK