简体   繁体   中英

How to get multiple values of last entered row in SQL Server 2008?

I have a question regarding identity or last entered values. I have a datatable in which there are 3 primary key i mean they are composite primary key which are 'tendercode', 'LocationID' and 'Layer' in which tendercode may have same number or at least one of them will be different like this as follow

TenderCode            LocationID            Layer
1                      MIN-001                L1
1                      MIN-001                L2
1                      AHM-001                L1
2                      MIN-001                L1
3                      AHM-001                L3

Like this are my table but the problem is I need to know which is the last entered record in trigger and "SELECT IDENT_CURRENT('tablename')" return only single value as per http://technet.microsoft.com/en-us/library/ms175098(v=sql.100).aspx

If you are in a trigger, then inserted table is what you are looking for.

Also, OUTPUT clause could help you.

Source here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM