Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Use of Identity Property to Resolve Concurrency Issues Rate Topic Display Mode Topic Options
Author
 Message
 Posted Wednesday, February 23, 2011 9:55 PM
 SSC Rookie Group: General Forum Members Last Login: Tuesday, December 29, 2015 8:02 PM Points: 33, Visits: 282
 Comments posted to this topic are about the item Use of Identity Property to Resolve Concurrency Issues Ajit AnanthramBlog - http://ajitananthram.wordpress.com
Post #1068652
 Posted Wednesday, February 23, 2011 11:43 PM
 Forum Newbie Group: General Forum Members Last Login: Monday, March 14, 2011 6:16 AM Points: 4, Visits: 30
 Removed the rude coment. I am sorry. Microsoft MVP 2006-2010
Post #1068680
 Posted Thursday, February 24, 2011 2:00 AM
 Ten Centuries Group: General Forum Members Last Login: Today @ 2:21 AM Points: 1,191, Visits: 1,375
 And your reply teaches us that you are ill-mannered and rude.Good article, Ajit. Very well written, clear and concise.
Post #1068717
 Posted Thursday, February 24, 2011 2:03 AM
 Forum Newbie Group: General Forum Members Last Login: Monday, March 14, 2011 6:16 AM Points: 4, Visits: 30
 You are right, I appologize.I am really sorry - I let my own problems take over. Microsoft MVP 2006-2010
Post #1068720
 Posted Thursday, February 24, 2011 2:14 AM
 Ten Centuries Group: General Forum Members Last Login: Monday, October 31, 2016 11:11 AM Points: 1,076, Visits: 3,229
 I'm not sure that setting the seed to the next number in logical order is the right way, Personally I would be setting the seed to start from a number somewhat larger than the current, simply to avoid the chance of collisions. In your example rather than setting the seed to Current+1 I would be inclined to set it to 100 (or some other factor of 10 depending on the current position), this way I could easily Identify the rows that were assigned by the new method and track any issues that were being created.As you state in the article,the introduction of Denali solves this type of problem with the new SEQUENCE statement. _________________________________________________________________________SSC Guide to Posting and Best Practices
Post #1068728
 Posted Thursday, February 24, 2011 2:18 AM
 Forum Newbie Group: General Forum Members Last Login: Friday, April 8, 2016 9:25 AM Points: 9, Visits: 118
 nice, good article never thought about how your could use vertical tables to solve that, and will also go and look at sequences in the next sql release!.Can I ask why in the original code the lock on the kvp was required for the duration of the whole buniness transaction. Could they just not of got the required key values into some temps using some short transactions before the main long running business process transaction took place? come to think about it, the kvp would not even need to be in a transaction if all they want is to increment a seed, a single update key statement to increment and at the same time assign the read value to a temp.thanks
Post #1068733
 Posted Thursday, February 24, 2011 3:04 AM
 Grasshopper Group: General Forum Members Last Login: Wednesday, May 29, 2013 9:33 PM Points: 21, Visits: 49
 Just my thought on this article...Why do we need a begin transaction statement at the start of the procedure USP_Business_Process. Everytime the sub-procedure : USP_Get_Value_For_Key is called, it will always have a unique value. So, the statement : BEGIN TRANSACTION Business_Process, should be after the call to the procedure USP_Get_Value_For_Key.i.e after the statement : SELECT @val -- Print key value for display,in the procedure: USP_Business_Process.This way there will be no blocking issue for the table: tbl_kvpHaven't tested this but think this should work.
Post #1068757
 Posted Thursday, February 24, 2011 3:05 AM
 Forum Newbie Group: General Forum Members Last Login: Sunday, June 28, 2015 12:01 PM Points: 8, Visits: 38
 Does your solution really solve the issue?What if the requirement was for no gaps in the key sequence? Doesn't using identities in this way lead to gaps in the key sequence if a transaction is rolled back.There is often a requirement to keep a continuous sequence, such as when assigning invoice numbers, in which case the original USP was correct, but your replacement may lead to gaps in sequence.
Post #1068758
 Posted Thursday, February 24, 2011 3:07 AM
 SSC-Enthusiastic Group: General Forum Members Last Login: Wednesday, September 30, 2015 3:00 AM Points: 168, Visits: 78
 May i know how it will help while updating the records. (ie. multiple users updating same record from the different sessions). As per your message, it will allow multiple users to update the same record.
Post #1068759
 Posted Thursday, February 24, 2011 3:32 AM
 SSC Veteran Group: General Forum Members Last Login: Wednesday, November 23, 2016 7:56 AM Points: 275, Visits: 383
 Why use the output syntax, table variable and dynamic sql?Wouldn't the following be simpler (no permissions issue on table if user running it only has access to SP either) :insert into ...set @outputId = scope_identity()
Post #1068770

 Permissions