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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:28:13+00:00 2026-06-13T19:28:13+00:00

I am writing a SP in SQL server ALTER PROCEDURE [dbo].[spAddUserBadge] AS BEGIN INSERT

  • 0

I am writing a SP in SQL server

ALTER PROCEDURE [dbo].[spAddUserBadge]
AS
BEGIN
    INSERT INTO dbo.SE_UserBadge
    (    
        [UID],
        BadgeID,
        BadgeAssignmentOrRenewalDate,
        BadgeExpiryDate ,
        AmountPaid, 
        Remarks ,
        AssignedBy          
    )
    VALUES
    (
        17,1, 12-12-2012, 12-12-2013, 0.00, '', ''
    )

    SELECT SCOPE_IDENTITY() AS id    
END
GO

SCOPE_IDENTITY is coming as NULL. where I am wrong?

  • 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-06-13T19:28:15+00:00Added an answer on June 13, 2026 at 7:28 pm

    The scope_identity will only return a value if there is a identity field, check you have an identity field.

    Unfortunately, you cannot alter an existing column to be an identity field using sql. To do this, you have to create a new column using something like ALTER TABLE dbo.SE_UserBadge ADD column name INT IDENTITY(1,1). Then you have to transfer any existing values using IDENTITY_INSERT dbo.SE_UserBadge ON with an update statement. Then you can drop the old column.

    Or you can use designer view in SSMS if the table isn’t too large.

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

Sidebar

Related Questions

I am writing a stored procedure in SQL Server 2008. Here I have a
I am using SQL Server. I'm writing a stored procedure that executes a series
I'm writing code to import dozens of moderate sized text files into SQL SERVER
I am working in SQL Server 2008. I am writing a stored procedure which
I am writing into two tables on SQL server row by row from C#.
I am writing data synchronization application between sql server and firebird. In firebird is
I'm learning SQL Server Compact for a program I'm writing that requries a local
I am writing an C# application for both SQL Server and Oracle Databases that
I am using SQL Server 2000. I am writing a trigger that is executed
I'm writing a simple C# program and want to use an SQL server to

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.