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

  • Home
  • SEARCH
  • 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 7070761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:36:20+00:00 2026-05-28T05:36:20+00:00

How to use the @@IDENTITY when I use INSERT SELECT ? DECLARE @ENTITYID AS

  • 0

How to use the @@IDENTITY when I use INSERT SELECT ?

DECLARE @ENTITYID AS BIGINT

INSERT INTO Quiz_QuizQuestion
SELECT @ENTITYID,
       @DIFICULTLEVELCODE,
       ENTITYID,
       @QuizEntityId,
       Title,
       [Description],
       [Description],
       Duration
FROM   Education_Question
WHERE  EntityID = 1 --THIS SELECT RETURN JUST 1 RECORD
SET @ENTITYID = @@IDENTITY

SELECT @ENTITYID // NULL  
  • 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. Editorial Team
    Editorial Team
    2026-05-28T05:36:20+00:00Added an answer on May 28, 2026 at 5:36 am

    You need not insert @@IDENTITY into the table in your scenario – you have to CREATE table with IDENTITY field like this:

    CREATE TABLE Quiz_QuizQuestion
    (
      EntityId int IDENTITY NOT NULL,
      ...
    )
    GO
    
    DECLARE @ENTITYID AS BIGINT
    
    INSERT INTO Quiz_QuizQuestion
    SELECT 
           @DIFICULTLEVELCODE,
           ENTITYID,
           @QuizEntityId,
           Title,
           [Description],
           [Description],
           Duration
    FROM   Education_Question
    WHERE  EntityID = 1 --THIS SELECT RETURN JUST 1 RECORD
    SET @ENTITYID = SCOPE_IDENTITY()
    
    SELECT @ENTITYID // NULL 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an insert sql with sql server and then call select @@identity straight
I'm using SQL Server and I want to use identity constraint in it I
I want to use GenerationType.IDENTITY for primary keys in my production MySQL system. But
Im considering use CSLA.NET 3.8 for example for Security and Identity Management on a
Can we use SPSecurity.RunWithElevatedPrivileges in SharePoint timer jobs? Under whose identity will the timer
What is the use of GetHashCode() ? Can I trace object identity using GetHashCode()
How do you a procedure like scope identity with linq want to use it
What is the difference between HttpContext.Current.Request.IsAuthenticated and HttpContext.Current.User.Identity.IsAuthenticated? Which one would you use in
I am loading some data into a temp table. I then use a cursor
Say I have this great query in my stored procedure. Select * from Temp

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.