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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:14:40+00:00 2026-05-29T05:14:40+00:00

I have a need for unique identifiers in my application. To that end, I

  • 0

I have a need for unique identifiers in my application. To that end, I created a table in my database that only contains 1 column ‘unique_id” (BIGINT) and 1 row.
The idea is to use a stored procedure to get the next identifier when I need it. I figured a 1-line operation like this would do the job:

UPDATE identifier_table SET unique_id = unique_id + 1 OUTPUT INSERTED.unique_id

Can someone confirm if this operation is atomic, or do I need to setup a lock on the table?

Thanks!

  • 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-29T05:14:40+00:00Added an answer on May 29, 2026 at 5:14 am

    It is atomic. It is just a single update statement, and will have no problem at all with concurrency since that will be managed by the engine with update locks. You can use OUTPUT as shown, or you can do something like this:

    DECLARE @unique_id bigint;
    
    UPDATE identifier_table
    SET
       @unique_id = unique_id + 1,
       unique_id = unique_id + 1;
    
    SELECT @unique_id uniqueid;
    

    If you make @unique_id an OUTPUT parameter, then you can get the value without a select statement or use it easily in another stored procedure.

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

Sidebar

Related Questions

I have a simple table that contains unique identifiers and a counter value for
MYSQL Database: I have a table of data that I need to put into
I have to write something in vbscript that need to use a unique set.
I have a Notes table with a uniqueidentifier column that I use as a
The problem is the following. There are multiple rows that have non-unique identifiers: id
in my Silverlight 4 application, I have a class myClass that contains a list
I have an application that is made up of the following: A central database
Using the Entity Framework that I generated. I have a Roles table created during
I have an application that contains 4 mutable arrays,i already displays one array of
I have created a single table in my primary DB called tblGlobalIDMapping that will

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.