April 24, 2012 at 5:38 am
Toreador (4/24/2012)
Thomas Abraham (4/24/2012)
this feature behaves as you would design it.Which is the reason I guessed wrong 😉
Ah yes, a SQL Server veteran. Burned by experience, conditioned to expect the unexpected.
[font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
Connect to me on LinkedIn
April 24, 2012 at 5:45 am
damn it! MISTAKE with the cycle/no cycle argument not related with the start value!
I didn't know that the start value for the sequence is the maximum for a ascending sequence. Let's learning. :w00t:
April 24, 2012 at 5:46 am
damn it! MISTAKE with the cycle/no cycle argument not related with the start value!
I didn't know that the start value for the sequence is the maximum for a ascending sequence. Let's learning. :w00t:
April 24, 2012 at 5:59 am
April 24, 2012 at 6:11 am
Thomas Abraham (4/24/2012)
bitbucket-25253 (4/24/2012)
... 2nd select returns 2147483646 yes the sequence is descending, but still not what is the supposed correct answer, so I am still confused and perplexed.Now I'm confused. What do you think is the supposed answer? I answered, and the answered page shows as correct 2147483646.
My apologies .... YOU ARE CORRECT
I should have finished my first cup of coffee before even attempting to answer and then wondering why what I selected was incorrect.
Again My apologies -
April 24, 2012 at 6:31 am
bitbucket-25253 (4/24/2012)
My apologies .... YOU ARE CORRECT
I should have finished my first cup of coffee before even attempting to answer and then wondering why what I selected was incorrect.
Again My apologies -
No apology necessary. However, it should demonstrate the esteem your signature carries that, in spite of getting it correct, I was willing to consider that you saw something I didn't.
[font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
Connect to me on LinkedIn
April 24, 2012 at 7:02 am
Thomas Abraham (4/24/2012)
I think if you give it some thought, this feature behaves as you would design it. The defaults seem the way I would hope they would - for a pleasant change.
Exactly. I heard of sequences at Dev Connections last month, and immediately thought of some "gotchas" that might make them somewhat difficult to work with. So I wrote some tests, whence came these questions (there's one more in the sequence by the way ; )
Every test I tried worked. Essentially, from what I could tell, you have to ignore the defaults or deliberately do something odd to break sequences in SQL 2012.
So (and I don't say this very often) Bravo, Microsoft!
April 24, 2012 at 7:05 am
sqlmunkee (4/24/2012)
So, the key bit here is that SQL will *decide* whether the sequence is ascending or descending based on the INCREMENT BY argument. That's a bit misleading if your just starting out with sequences and SQL 2012 (like me) 🙂 Good question !
I agree that it seems misleading or confusing. That's why I always code the details even if they are the defaults and not required. That way, there is no question when someone else reads the code. It gets a little wordy but it alleviates confusion.
It's good to learn the new stuff. 🙂
April 24, 2012 at 9:24 am
OCTom (4/24/2012)
sqlmunkee (4/24/2012)
So, the key bit here is that SQL will *decide* whether the sequence is ascending or descending based on the INCREMENT BY argument. That's a bit misleading if your just starting out with sequences and SQL 2012 (like me) 🙂 Good question !I agree that it seems misleading or confusing. That's why I always code the details even if they are the defaults and not required. That way, there is no question when someone else reads the code. It gets a little wordy but it alleviates confusion.
It's good to learn the new stuff. 🙂
Good point, always code the details which should remove any ambiguity or confusion.
Good question.
April 24, 2012 at 9:26 am
Toreador (4/24/2012)
Thomas Abraham (4/24/2012)
this feature behaves as you would design it.Which is the reason I guessed wrong 😉
+1 😀
Great question. Need to dig into the new 2012 features more.
Cheers
April 24, 2012 at 9:41 am
Great question. Looking forward to using this feature in an upcoming project....
Rob Schripsema
Propack, Inc.
April 24, 2012 at 9:56 am
Good one
...[-2147483648,-2147483647, ... ,2147483646,2147483647],[-2147483648,-2147483647, ... ,2147483646,2147483647]...
IgorMi
Igor Micev,My blog: www.igormicev.com
April 24, 2012 at 10:08 am
Excellent question. I had to read and re-read BOL to get it right. Seems that sequences with default values are tricky to understand, but I found that reading the specific points make sense to their behavior.
From BOL (http://msdn.microsoft.com/en-us/library/ff878091.aspx):
START WITH <constant>
The first value returned by the sequence object. The START value must be a value less than or equal to the maximum and greater than or equal to the minimum value of the sequence object. The default start value for a new sequence object is the minimum value for an ascending sequence object and the maximum value for a descending sequence object.
INCREMENT BY <constant>
Value used to increment (or decrement if negative) the value of the sequence object for each call to the NEXT VALUE FOR function. If the increment is a negative value, the sequence object is descending; otherwise, it is ascending. The increment cannot be 0. The default increment for a new sequence object is 1.
"El" Jerry.
April 24, 2012 at 11:03 am
Thanks for an easy one!
Viewing 15 posts - 16 through 30 (of 40 total)
You must be logged in to reply to this topic. Login to reply