Tuesday, March 27, 2012

Getting the Id of the row that i inserted with SQL 2005

Hi,

I use a Stored Procedure who works very well

...
INSERT INTO Computers (CategoryID, SubCategoryID, .....
VALUES (@.CategoryID, @.SubCategoryID, ....
...

But as soon as it creates the new row, i want to be able to get the Id (ComputerId) of this row. I use ComputerId as the primary key.

How can i do that? I code in VB.

Thanks

Add "RETURN SCOPE_IDENTITY()" to your stored procedure. Then you should be able to pick up this value as the stored procedure's return value.

|||

Thank you very much it works!

No comments:

Post a Comment