Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger help!!!

Status
Not open for further replies.

lucyv80

Programmer
Mar 23, 2006
1
US
I have the following trigger on a table

CREATE TRIGGER tr_orders_setFY ON [dbo].[orders]
FOR INSERT, UPDATE
AS
UPDATE orders SET fy = dbo.fn_leos_getFY(dtstamp) WHERE fy IS NULL

The problem is when I add a record using RS.AddNew() and retrieve the id of the last record added temp = RS("field") a number is not returned. When I remove the trigger everything works fine.

Any help will be greatly appreciated.

Thanks!
 
Quote from BOL ...

"If the statement fires one or more triggers that perform inserts that generate identity values, calling @@IDENTITY immediately after the statement returns the last identity value generated by the triggers."

I believe
... UPDATE orders SET fy ...
causes @@IDENTITY to reset

and, no, I don't know how to work around. Sorry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top