>>When you feel 100% (I wish you do get 100% well, regardless of my question) and if you have a moment, could you, please, educate me on what is "factory sequence object"? Even if only in a few words. TIA.
>
>For years, database people have wanted something along the lines of a table-independent identity value, that's unique across all rows in ALL tables of a database (as opposed to a normal identity that's only capable of being unique within a single table)
>
>So imagine if you have a Prodmaster, CustMaster, and GLmaster.
>
>The unique value for the identity keys for the first three rows in Prodmaster would be 1,4, 7......for the Custmaster, 2, 5, 8....and for GLMaster, 3, 6, 9
>
>So when a row is appended, the integer key would be unique across all tables in the database, not just the single table.
>
>You can do this with a uniqueidentifier datatype and either the functions new() or newsequentialid() and it will work - but a uniqueidentifier is 32 characters and 16 bytes....but many would prefer cross table uniqueness with a four byte integer (which compresses better) than a 16 byte alphanumeric.
>
>So DBAs would set up a special stored procedure with a one row, one column control table that held the next INT to be used. The proc would use the same type of logic being discussed in this thread - updating the control table with the next value (usually one) and assigning it to a variable in the same line of code (and using the necessary locks). Someone here on the UT the code for it has been posted many times. Some call it a factory because it's spitting out the next value to be used, and a sequence object because it's generating the next numerical sequence from this one row, one column control table that holds the next value to be used.
>
>Now, enter SQL 2012. SQL 2012 has a new sequence object built into the database engine. So you can use it to get table-independent identity values, and you don't need to use a special stored procedure of your own anymore.
>
>Hope that helps.
Very helpful and easy to understand explanation. Thank you very much!
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham