|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 12:38 AM
Points: 14,
Visits: 246
|
|
|
|
|
|
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
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 1:59 AM
Points: 1,126,
Visits: 924
|
|
And your reply teaches us that you are ill-mannered and rude.
Good article, Ajit. Very well written, clear and concise.
|
|
|
|
|
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
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Yesterday @ 3:38 AM
Points: 803,
Visits: 2,123
|
|
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
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 6:37 AM
Points: 6,
Visits: 78
|
|
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
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, January 24, 2013 12:53 AM
Points: 20,
Visits: 46
|
|
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_kvp
Haven't tested this but think this should work.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, April 08, 2013 5:14 AM
Points: 8,
Visits: 32
|
|
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.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, March 18, 2013 4:31 AM
Points: 168,
Visits: 64
|
|
| 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.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 2:25 AM
Points: 179,
Visits: 210
|
|
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()
|
|
|
|