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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:43:54+00:00 2026-06-04T17:43:54+00:00

I have a table in SQL Server 2008 R2 that holds positions for different

  • 0

I have a table in SQL Server 2008 R2 that holds “positions” for different companies.

I have a function GET_KEY that creates a position number by performing a SELECT MAX over the table. [I can not use Identity Increment because the position number needs to be the first available number for a particular company]

SELECT @v_position_no = max(POSITION_NO) + 0.01 
FROM POSITIONS WHERE COMPANY_NO = @p_company_no 

I have a function that copies a position COPY_POS.

I want to copy an existing position twice, but to assign each position an appropriate position number.

I run GET_KEY, then COPY_POS, then GET_KEY, then COPY_POS

However, the positions table locks. I am almost positive (and it is logical) that this is because there a conflict between GET_KEY and COPY_POS. [The problem only occurs if I try and do GET_KEY and COPY_POS twice in succession]


What I tried…

  1. I tried encasing each of GET_KEY and COPY_POS in a BEGIN TRAN and COMMIT TRAN, but this didn’t work.

  2. The entire stored procedure is contained in a BEGIN TRY and END TRY and I tried removing this, but this also didn’t work…

Does anyone have any ideas?

Thank you!

  • 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-04T17:43:55+00:00Added an answer on June 4, 2026 at 5:43 pm

    Simply add a WITH (nolock) to the Select statement!

    SELECT @v_position_no = max(POSITION_NO) + 0.01 
    FROM POSITIONS WITH (nolock) WHERE COMPANY_NO = @p_company_no
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an interesting table query (SQL Server 2008) that fails with a different
I have an sql server 2008 db table that holds links to articles. My
I use SQL Server 2008 R2 and have a table that I want no
I'm using SQL Server 2008 and I have a table that has a 'Status'
I have a table which contains my ads that can be searched in sql-server-2008.
I have an SQL Server 2008 database with a table that has a column
I have a table in SQL Server 2008 that looks kind of like this:
I have a database table (SQL Server 2008 R2 Express edition) that has a
I have created a MedicalLabResult table on Sql server 2008 that have a Result
I am using SQL Server 2008. I have a table (TBL_FILE) that stores user

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.