sql server - Update newly inserted non-nullable foreign key, with inserted value of a trigger -
i not know if possible.
at moment have following trigger:
create trigger trig_insert_a on insert begin declare @expdate datetime2; declare @identifier uniqueidentifier; set @expdate = dateadd(year, 1, getdate()); set @identifier = newid(); insert b(uniquevalue, expirationdate) values (@identifier, @expdate); end [edit]
the previous trigger create record in table "b", when new record created in table "a". kinda trying achieve, maybe should try explain other way around: before insert table "a", want create record in table "b", take id of newly created record in "b", , set "fk_bid" value.

[/edit]
Comments
Post a Comment