Sequences II

  • Comments posted to this topic are about the item Sequences II

  • Guess I need to learn more about the new features in 2012. Good question.

    http://brittcluff.blogspot.com/

  • Nice question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • 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

  • 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.

  • 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

  • This was removed by the editor as SPAM

  • I fell into the same trap as tommyh... I should have looked it up.

    -- Stephen Cook

  • 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]

  • 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]

  • 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

  • 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.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • 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

  • Thomas Abraham (4/24/2012)


    this feature behaves as you would design it.

    Which is the reason I guessed wrong 😉

  • 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