Query regarding SP's
-
If suppose we have to add a row in a table, using insert and there is a primary key(PKID) which is auto incremented. After executing the SP how will we know that what being the value of that key, i.e. to retrieve it from the SP itself, i had heard that there is a particular command for that Can someone help me plz................
-
If suppose we have to add a row in a table, using insert and there is a primary key(PKID) which is auto incremented. After executing the SP how will we know that what being the value of that key, i.e. to retrieve it from the SP itself, i had heard that there is a particular command for that Can someone help me plz................
-
If you want to get the PKID(auto incremented) then you can use @@IDENTITY for that. This will give you the PKID of just inserted recored. :)
Best Regards, Apurva Kaushal
I didn't get your reply and what I soppose that you fine mine question unclear So let me clarify it I am asking that Suppose there is an SP that store some information Inserted by user and it generate automatically an ID (identity element) for that particular information. Now after calling this SP in some of the function I want the PKID that is assigned to recent information, How can I retrive this PKID ??
-
I didn't get your reply and what I soppose that you fine mine question unclear So let me clarify it I am asking that Suppose there is an SP that store some information Inserted by user and it generate automatically an ID (identity element) for that particular information. Now after calling this SP in some of the function I want the PKID that is assigned to recent information, How can I retrive this PKID ??
-
Do a select statement using this:
SELECT IDENT_CURRENT('table_name')
This will return the last inserted PK in the table orSELECT @@IDENTITY
Try sql help on these two functions and see how they work exacly:-DOh fine and Thanku vary much Mr. Devil and Mr. Apurva