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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:54:23+00:00 2026-06-12T23:54:23+00:00

I created this pretty basic stored procedure, that gets called by our cms when

  • 0

I created this pretty basic stored procedure, that gets called by our cms when a user creates a specific type of item. However, it looks like there are times when we get two rows for each cms item created with the same data, but an off-by-one SourceID. I don’t do much SQL work, so this might be something basic – but do I need to explicitly lock the table somehow in the stored procedure to keep this from happening?

Here is the stored procedure code:

BEGIN
    SET @newid = (SELECT MAX(SourceID)+1 from [dbo].[sourcecode])

    IF NOT EXISTS(SELECT SourceId from [dbo].[sourcecode] where SourceId = @newid)
        INSERT INTO [dbo].[sourcecode]
            (
                SourceID,
                Description,
                RunCounts,
                ShowOnReport,
                SourceParentID,
                ApprovedSource,
                Created
            )
        VALUES
            (
                @newid,
                @Desc,
                1,
                @ShowOnReport,
                1,
                1,
                GetDate()
            )

    RETURN @newid
END

and here is an example of the duplicated data (less a couple of irrelevant columns):

SourceId    Description Created
676         some text   2012-10-17 09:42:36.553
677         some text   2012-10-17 09:43:01.380
  • 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-12T23:54:24+00:00Added an answer on June 12, 2026 at 11:54 pm

    I am sure this has nothing to do with SP. As Oded mentioned, this could be the result of your code.
    I don’t see anything in the stored procedure which is capable of generating duplicates.
    Also, I wouldn’t use MAX(SourceId) + 1. Why don’t you use “Auto Increment” if you want a new Source Id all the time anyways?

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

Sidebar

Related Questions

I bought this program that created a pretty nice imageuploader flash script however I
Okay, so, this code is pretty basic. The user inputs an answer into a
I've created a pretty basic system here at work that does what Google analytics
I created this regex to match all words that start with @ in my
This might be pretty basic, but was very curious to know. Here's the code
I've created a basic website using the Orchard CMS, and attempted to deploy it
I know this a pretty basic question, and already found another ones like mine,
Apologies, this is pretty basic. I have abstracted my static html navigation bar to
I have created a menu. It's pretty basic but I got a problem which
I have created a pretty basic Flash website for a client and am having

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.