April 23, 2012 at 8:27 pm
Comments posted to this topic are about the item Sequences II
April 23, 2012 at 8:28 pm
Guess I need to learn more about the new features in 2012. Good question.
http://brittcluff.blogspot.com/
April 23, 2012 at 11:15 pm
Nice question, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
April 23, 2012 at 11:20 pm
Now i cant test this. But is that answer really accurate. Reading the link... it doesnt sound so.
Since its an int the values defaults become
MinValue : -2,147,483,648
MaxValue : 2,147,483,647
Startvalue will be MinValue (since its not given).
So add -1 to -2,147,483,648 and it should loop... but only if option is CYCLE and the default is NO CYCLE... so shouldnt it give an error instead?
/T
April 24, 2012 at 12:51 am
tommyh (4/23/2012)
Startvalue will be MinValue (since its not given).
Check reference again. Start value is different whether sequence is ascending or descending.
April 24, 2012 at 12:56 am
dawryn (4/24/2012)
tommyh (4/23/2012)
Startvalue will be MinValue (since its not given).Check reference again. Start value is different whether sequence is ascending or descending.
You are so right.
/T
April 24, 2012 at 1:56 am
This was removed by the editor as SPAM
April 24, 2012 at 3:35 am
I fell into the same trap as tommyh... I should have looked it up.
-- Stephen Cook
April 24, 2012 at 4:04 am
Stephen E. Cook (4/24/2012)
I fell into the same trap as tommyh... I should have looked it up.
Me too... trapped, hook, line and sinker... doh! :blush:
_____________________________________________________________________
[font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]
April 24, 2012 at 4:20 am
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 !
[font="Courier New"]sqlmunkee[/font]
[font="Courier New"]Bringing joy and happiness via SQL Server since 1998[/font]
April 24, 2012 at 5:29 am
Excellent question. On a new feature, minimum code to make your point, clear cut answer, and several issues demonstrated at once. Bravo! (and Thanks!)
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.
[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:30 am
I am some what confused and perplexed for when I run
(in Denalli CTP3)
SELECT name, start_value FROM sys.sequences;
the return values are:
name start_value
SSC_ROCKS2147483647
and that start value is a POSITIVE VALUE.
April 24, 2012 at 5:35 am
bitbucket-25253 (4/24/2012)
I am some what confused and perplexed for when I run(in Denalli CTP3)
SELECT name, start_value FROM sys.sequences;
the return values are:
name start_value
SSC_ROCKS2147483647
and that start value is a POSITIVE VALUE.
MAX for INT is 214748647, which it uses as start value because INCREMENT BY -1 indicates the sequence should be DESCENDING.
[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:35 am
Thomas Abraham (4/24/2012)
this feature behaves as you would design it.
Which is the reason I guessed wrong 😉
April 24, 2012 at 5:36 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 only seems logical to me.
If the INCREMENT BY is negative, the sequence will automatically be a descending one, as you will always "take a step back".
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 15 posts - 1 through 15 (of 40 total)
You must be logged in to reply to this topic. Login to reply