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 95223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:37:29+00:00 2026-05-10T23:37:29+00:00

I can’t figure out how to get the SCOPE_IDENTITY() back to my variables from

  • 0

I can’t figure out how to get the SCOPE_IDENTITY() back to my variables from an SQL2005 Store Procedure.

My sSQL String:

sSQL = 'EXEC [sp_NewClaim] ' & Chr(34) & ClaimNumber & Chr(34) & ', ' & Request.Cookies('UserID') & ', ' & Request.Cookies('MasterID') & ', ' & Chr(34) & strRestaurante & Chr(34) & ', ' & Chr(34) &  Fecha & Chr(34) & ', ' & Chr(34) & Hora & Chr(34) & ', ' & Chr(34) & Request('Tiempo') & Chr(34) & ', ' & Chr(34) & Request('Luz') & Chr(34) & ', ' & Chr(34) & Request('Desc') & Chr(34) & ', ' & Chr(34) & Request('incidente') & Chr(34) & ', ' & Chr(34) & Request('codigos') & Chr(34) & ', False, 0; SELECT RecordNumber = SCOPE_IDENTITY()' 

My sSQL Output:

EXEC [sp_NewClaim] 'W200811', 7, 8, 'Otro -- WORK PLEASE', '11/19/2008', '01:19 PM', 'Nublado', 'Mala', 'asdasd', 'uyiuyui', 'C-Junta', False, 0; SELECT RecordNumber = SCOPE_IDENTITY() 

Executing my SQL Command:

Set rsData= Server.CreateObject('ADODB.Recordset') rsData.Open sSQL, conDB, adOpenKeyset, adLockOptimistic 

Trying to Output the SCOPE_IDENTITY() Produces an Empty Variable (No Output):

Response.Write('<br />Record Number: ' & rsData('RecordNumber')) 

The Store Procedure runs correctly. My Information gets stored into my database with out problems. RecordNumber is the Column with the Identity, and the Store Procedure has defined @RecordNumber as an Output:

USE [db_clcinsurance_com] GO  SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE sp_NewClaim  (     @ClaimNumber nvarchar(50),     @blah............     .................     @RecordNumber INT OUTPUT     ) AS  BEGIN      INSERT INTO Accidente (ClaimNumber,........., RecordNumber)      VALUES (@ClaimNumber,....., @RecordNumber)      SET @RecordNumber = SCOPE_IDENTITY();  END 
  • 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-10T23:37:29+00:00Added an answer on May 10, 2026 at 11:37 pm

    For your stored procedure, do this:

    CREATE PROCEDURE sp_NewClaim  (     @ClaimNumber nvarchar(50),     @blah............     ................. ) AS BEGIN     SET NOCOUNT ON;      INSERT INTO Accidente (ClaimNumber,........., RecordNumber)         VALUES (@ClaimNumber,....., @RecordNumber)      SELECT SCOPE_IDENTITY() END 

    And then get the id the same way you’d retrieve any other query result.

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

Sidebar

Related Questions

Can't figure out how to do this in a pretty way : I have
Can't seem to figure out what's wrong with the simple getJSON call below. It's
Does anyone know how can I replace this 2 symbol below from the string
Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can any one tell, how to get the result of LINQ query contains group
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can anybody tell what is the best(easy) way to sort the following string 'index'
Can someone explain why, when a query should be returning one string item only
Can I prevent an .apk from being installed if unknown sources is checked?
Can any one help me in sorting this out in sed/awk/perl Input file Start

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.