Forums

ASP

This topic is locked

asp sql insert & return identity

Posted 30 May 2002 12:27:10
1
has voted
30 May 2002 12:27:10 rinus flipse posted:
Hello everyone,

I'm not sure if this post belongs in asp or sql, but here we go:

I'm trying to insert a row in a mssql server 2000 db and return the identity. This is done from a asp page.

sqlserver help advises something like:
insert into TABEL values (SOMETHING, SOMETHING)
select @@identity as SOMETHING

this returns nothing.

Looking in several posts all over the internet reveals that nocount should be set:

set nocount off
insert ...
set nocount on

This works, the identity is returned, but when I check the database, 4 identical rows are inserted! (instead of just the one)

Any help would be appreciated.

Dennis

Reply to this topic