Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Is it possible to change the value of an inserted item from within an insert trigger?

 

Such as

inserted.[field] = 1

 

There are several reasons, but one of them is to replace a value with a default if the value doesn't meet a FK Constraint so as to allow the insert to happen.

Posted
You can't update the "inserted" table and since the incoming row is violating the FK constraint it is not going to be allowed to be inserted. Your best bet is to adjust the FK value at the application or stored procedure level. There might be a gruesome hack out there somewhere though.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...