Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 179347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:23:27+00:00 2026-05-11T14:23:27+00:00

How can I get back the autogenerated ID for a new record I just

  • 0

How can I get back the autogenerated ID for a new record I just inserted? (Using ASP classic and MSSQL 2005)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:23:28+00:00Added an answer on May 11, 2026 at 2:23 pm

    Thanks all who suggested SELECT SCOPE_IDENTITY(). I was able to create a stored procedure:

    USE [dbname] GO  SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[spInsert] (    @Nn varchar(30) ) AS BEGIN TRANSACTION InsertRecord     INSERT INTO A (Nn)     VALUES (@Nn)     SELECT NewID = SCOPE_IDENTITY()   -- returns the new record ID of this transaction    COMMIT TRANSACTION InsertRecord 

    and call the sproc using VB:

    Dim strNn '<- var to be passed' Set cn = Server.CreateObject('ADODB.Connection')  connectString = 'DSN'  cn.Open connectString, 'user', 'PW0rd'  Set rs = Server.CreateObject('ADODB.Recordset')  set rs = cn.Execute('EXEC [dbname].[dbo].[A] @Nn=' & strNn) 'return the value' resultID = rs(0) 

    I can now use resultID anytime I refer to the newly created ID.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't seem to get back on track with this one. I simply put
Can I get the Contents in Android System's Back Stack so I can print
How can I get a simple call back when a HID device, or at
How can I get the all the 'name' and 'city' value back in an
How can I get a direction vector representing the direction the back of the
How can I get the array data from a JSON sent back by my
I can't get the ObjectId for a model to return back with a value
I need to undo the following ASP.Net processes in PHP so I can get
I am using simpleXML and get back the result like so: SimpleXMLElement Object (
Can get all triples with value null in specific field? All people with date_of_birth

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.