I want to know which record is the last inserted on Detail Table B in the following order… for example If I have :
1 row Header Table A
--------------------
1 row Detail Table B
2 row Detail Table B
3 row Detail Table B
4 row Detail Table B (last)
I want to do some T-SQL or run a procedure if the 4 row is inserted… Thanks in advance!
Using SQL-Server 2000
Have a look at some help on triggers as advised above and then maybe look at the special Inserted and Deleted tables created and used by triggers.
Two special tables are used in trigger statements: the deleted table and the inserted table. Microsoft® SQL Server automatically creates and manages these tables. You can use these temporary, memory-resident tables to test the effects of certain data modifications and to set conditions for trigger actions; however, you cannot alter the data in the tables directly.
Every row that is inserted or deleted via a trigger is done via these tables i believe.
As you do your insert you could possibly query the insert table to find the last row that was pushed through it.