• mtassin (5/1/2012)


    marlon.seton (5/1/2012)


    I think this question indicates that using default values with a new item like CREATE SEQUENCE isn't a great idea. I, for one, will be defining everything (AS, START WITH, INCREMENT BY, MINVALUE, MAXVALUE, CYCLE, CACHE) if I get round to using sequences in SQLServer. I know it might look wordy and take up a few more lines but for the sake of clarity, and potential help in solving problems, I would think it worth it.

    Defaults aren't bad... a default sequence is a bigint starting at -9,223,372,036,854,775,808 and counting up.

    In this case the qotd started at the bottom end of the int and counted down.

    This QotD (and Sequences I and II) were written to highlight specific defaults for sequences. No, defaults in and of themselves aren't bad -- indeed with sequences Microsoft has done an OK job of ensuring that if you rely on defaults, things won't break too badly.

    The problem comes in when you specify some values but leave others at default, as in this scenario, or when you haven't used a feature for a while, and think a default is A when it's actually B.

    If you explicitly define each value, you not only can't easily make that kind of mistake, but you've also documented the structure completely in one place rather than relying on documentation elsewhere. This reduces the chance that someone else (a coworker or even a replacement) could misunderstand what the sequence is doing.