Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning PK from Insert Statement
Message
General information
Forum:
ASP.NET
Category:
Databases
Environment versions
Environment:
VB.NET 1.1
Database:
MS SQL Server
Miscellaneous
Thread ID:
01090504
Message ID:
01090688
Views:
14
Hi Eric,
I wonder why this only works for me if I use Scope_Identity() function, otherwise I get "Invalid column name 'SCOPE_IDENTITY'" message in Query Analizer.
Thank you.

>How do you insert your data into the database?
>
>If you are sending a INSERT INTO statement, just add a "select Scope_Identity" at the end of your query and be sure you call your query reading the result back (into a datareader for example).
>
>Your query string should look like this:
>
>strSQL = "insert into tablename(fields list) values(values list) select Scope_Identity"
>
>
>>Hello,
>>I have a stored procedure that inserts a record into a table. What I would like to do is return the PK that is created for the records back to my application. I have done a little research already and it seems like Scope_Identity() is the function I want, but I can't figure out how to get that back to my app.
>>
>>Thanks,
>>MAC
Doru
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform