I'm using SQL Server 2005 with VB.Net. My question is related to Insert triggers in SQL 2005.
Is it possible to update columns of a new record during a Insert Trigger? When the new record is inserted, I would like to set the values of several columns in those new records during the Insert trigger for the table. A trivial example of such an attempt is given below (note this isn't my actual trigger, just a simple example to discuss). I think the problem may be related to referencing the new records identity column (RowID in the example) during the Insert trigger. I'm not 100% certain that the identity value is actually assigned before the Insert trigger fires, so this might be my problem.
When I try similar code for my database I get the following error. Note that I'm directly modifying the data table in the Server Explorer from the VB.NET 2005 IDE. When the new row is committed, the following error occurs. The error is cleared by running the query again (right click data table and select Execute SQL from the popup menu).
"This row was successfully committed to the database. However, a problem occurred when attempting to retrieve the data back after the commit. Because of this, the displayed data in this row is read-only. To fix this problem, please re-run the query."
Start Free Trial