Results 1 to 2 of 2

Thread: @@Identity

  1. #1
    Hemant Visal Guest

    Default @@Identity

    I am using a sql squery to return the identity field when I fire a SQL query. My database is SQL server 7.0. But I am getting database error and I am not able to figure out where I am going wrong . Whether I should open the recordset in some different mode? Please let me know about it. <BR><BR>userid field is identity field. <BR><BR>strQuery = "SET NOCOUNT ON;insert into users( fields ) values ( values ); Select @@Identity as userid" <BR>objRS.open strQuery, objConn, 1,1,1 <BR><BR>Response.Write objRS("userid") <BR><BR>I am trying different things but still is not working. So please let me know where I am going wrong. <BR>

  2. #2
    Richard A. Lowe Guest

    Default RE: @@Identity

    ADO uses the ; to indicate two SQL batches. The second doesn&#039t get called untill you call the NextRecordset method. HOWEVER, try just replacing it with a new line:<BR><BR>= "SET NOCOUNT ON;insert into users( fields ) values ( values )" & vbCrLf & "Select @@Identity as userid" <BR><BR>I have had inconsistancies with this syntax, but perhaps it will work for you. This should update your table and get the identity in one action.<BR><BR>Richard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts