|
-
May 20th, 2005, 09:55 AM
#1
Thread Starter
Hyperactive Member
@@identity not returning any value [resolved]
Can any one see what's wrong with this? I'm calling it from an asp page. It's inserting the value but not returning anything in the recordset......
Code:
CREATE PROCEDURE spVan_Start AS
insert into tblVan_counter (q1) values (1)
select @@identity
GO
Last edited by thebloke; May 20th, 2005 at 10:10 AM.
Reason: resolved
The Bloke
www.blokeinthekitchen.com
making cooking cool for blokes
-
May 20th, 2005, 10:00 AM
#2
Re: @@identity not returning any value
Add a Set NoCount On statement before the Insert statement. Or better yet, return the new identity value in an Output parameter and eliminate the overhead of a recordset.
-
May 20th, 2005, 10:04 AM
#3
Fanatic Member
Re: @@identity not returning any value
If you're using SQL Server 2000 try returning:
Code:
SELECT SCOPE_IDENTITY()
instead as @@IDENTITY is global and will not necessarily return you the ID of the table you just inserted into (especially if you have triggers on that table that insert into another table!)
-
May 20th, 2005, 10:09 AM
#4
Thread Starter
Hyperactive Member
Re: @@identity not returning any value
combined both and it works:
Code:
CREATE PROCEDURE spVan_Start AS
SET NoCount On
insert into tblVan_counter (q1) values (1)
select SCOPE_IDENTITY()
GO
Thanks guys
The Bloke
www.blokeinthekitchen.com
making cooking cool for blokes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|