Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Article: Returning @@IDENTITY back to an ASP Page
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ask SQLTeam Question

0 Posts

Posted - 08/17/2000 :  19:30:46  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
Gareth writes "Hi, I'd be so relieved if you could sort this out . . . I'm trying to get the value of @@IDENTITY from SQL Server into an ASP variable (via a recordset) - however I get an ASP error reporting that the value in the recordset (selected as 'ident') can't be found. What's going on . . . Thanks!"

Article Link.

Starting Member

0 Posts

Posted - 09/07/2000 :  16:33:11  Show Profile  Reply with Quote
Try this solutions

You try this way.Because @@Identity assign in temporary variable then fetch value of last inserted.
'SELECT FirstName + ' ' + LastName AS "Employee Name", IDENTITYCOL AS "Employee ID" FROM Northwind.dbo.Employees'.

or try this

'If the statement did not affect any tables with identity columns, @@IDENTITY returns NULL'

Now u may get value of identity.This is my gess only.

If you get any ideas from the above i will really Appreciate you.
If you don't get any help from above i am really sorry.
Pls let me know.
my id is

Go to Top of Page

Starting Member

0 Posts

Posted - 01/26/2001 :  16:38:25  Show Profile  Reply with Quote
Other solution to NoCount

Instead of setting nocount off to avoid that error, you could do this

Set objRs = objRs.NextRecordSet

Go to Top of Page

Starting Member

1 Posts

Posted - 05/28/2008 :  12:28:19  Show Profile  Reply with Quote
I dont use ASP I use vb 2005. How would I get the answer to the @@identity in my vb2005 code?

Lonnie R Thomas
Go to Top of Page

Cybernetic Yak Master

11752 Posts

Posted - 05/28/2008 :  12:48:25  Show Profile  Visit spirit1's Homepage  Reply with Quote
with dataset and dataadapter or executescalar method of sqlcommand object.
if you're going to use executescalar then you have to return with "select @@identity" in your sproc.

also use scope_identity() instead of @@identity

Causing trouble since 1980
Speed up SSMS development: <- version 1.0 out!
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000