You need a field which is ordered by the insert - like an identity or timestamp or sequence set by a trigger.
If you are a multi-user system and want the record that your thread has just inserted then easiest is an identity with scope_identity. But you might want to have a look at the design and change things so that you know the PK of the rec you are inserting.
======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
By logical if you inserting data into tablewith primary key then the data you have inserted is beeing maximum.
suppose that the table is 'customer' and 'customer_no' is promary key: then
select * from customer where customer_no=
(select max(customer_no) from customer)
in this way you are getting the last inserted record(if there has primary key)
>> By logical if you inserting data into tablewith primary key then the data you have inserted is beeing maximum.
Only if the PK is an increasing value e.g. an increasing identity or timestamp.
Doesn't work for guids for instance or decreasing identity.
Need more info about the system to give an answer.
======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.