SQL Transactions generating incorrectly

  • In the database I "manage" we are having a strange occupance and I am sorry if my attempt to explain it is unclear.

    When a new part is received initially, it gets a sequential number assigned to it along with a timestamp. In this instance, a part was received as number 1000 at 10AM, and the same part was received as number 1001 at 9:59AM. I am trying to figure out why the single action generated 2 transactions, and why a higher "id" number was generated for a transaction that occurred earlier than the one before it. Is this a known issue with SQL 2005?

  • You're going to have to give a lot more detail than that...

    How is the sequential number generated?

    How is the timestamp generated?

    What's the code that inserts this? Where does it get called from (what requests that a part be inserted) and how?

    And that's just the bare minimum.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I don't have access to the code itself, but I was told by the programmer that when a part is added, the first thing it does is check to see if it already exists, so he doesn't believe the problem is with the code but possibly with an issue in SQL. I was just posting here to see if this has happened to anyone else, but I don't really have the background to dig into this problem.

  • Sounds like a lot of developers I've worked with. "My code's perfect, it must be something else" 😉

    Without knowing how those values are generated it's going to be impossible to offer any useful advice. SQL's not going to duplicate an insert unless it was told to do so. To get to the root of this would require looking over the code that does the check and the insert and digging into that.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • If you don't have access to the code but have access to the SQL Server you can use the SQL Server Profiler to create a Trace and see what SQL is being executed. You'll be able to determine if it's the code or not.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply