Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

Sequences I Expand / Collapse
Author
Message
Posted Monday, April 16, 2012 10:27 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, September 12, 2014 7:18 PM
Points: 1,325, Visits: 1,693
Comments posted to this topic are about the item Sequences I
Post #1284658
Posted Monday, April 16, 2012 10:28 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, August 28, 2014 2:39 AM
Points: 1,904, Visits: 2,846
got it wrong, as the correct answer wasn't listed.
your syntax is wrong in, sequence wouldn't be created to start of with...no increment value, no 'AS'..etc.


----------------------------------------------
Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.
Post #1284659
Posted Tuesday, April 17, 2012 12:41 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 1:54 PM
Points: 13,735, Visits: 10,705
Henrico Bekker (4/16/2012)
got it wrong, as the correct answer wasn't listed.
your syntax is wrong in, sequence wouldn't be created to start of with...no increment value, no 'AS'..etc.


When I look at BOL I see the following:


CREATE SEQUENCE [schema_name . ] sequence_name
[ AS [ built_in_integer_type | user-defined_integer_type ] ]
[ START WITH <constant> ]
[ INCREMENT BY <constant> ]
[ { MINVALUE [ <constant> ] } | { NO MINVALUE } ]
[ { MAXVALUE [ <constant> ] } | { NO MAXVALUE } ]
[ CYCLE | { NO CYCLE } ]
[ { CACHE [ <constant> ] } | { NO CACHE } ]
[ ; ]


This means that everything is optional except the first line. MSDN also lists every default value for every line.

edit: Example E in the MSDN article is exactly the same as the QotD.

Anyway, awesome question. Really like the SQL Server 2012 questions!




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1284691
Posted Tuesday, April 17, 2012 12:42 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 8:09 AM
Points: 3,961, Visits: 5,198
Interesting question, thanks...

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1284692
Posted Tuesday, April 17, 2012 1:17 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 12:53 AM
Points: 2,529, Visits: 2,402
I am curious to know how many developpers will use default value for "START WITH". In most cases will be a negative number.
Post #1284703
Posted Tuesday, April 17, 2012 1:21 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 1:54 PM
Points: 13,735, Visits: 10,705
Carlo Romagnano (4/17/2012)
I am curious to know how many developpers will use default value for "START WITH". In most cases will be a negative number.


They will all be negative, except for tinyint.
In most cases this shouldn't be a problem, unless you are using the sequence for generating surrogate keys and you have tied special meaning to some of them.

For example: 0 equals unknown, -1 equals not applicable.




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1284704
Posted Tuesday, April 17, 2012 2:06 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 12:53 AM
Points: 2,529, Visits: 2,402
Koen Verbeeck (4/17/2012)
Carlo Romagnano (4/17/2012)
I am curious to know how many developpers will use default value for "START WITH". In most cases will be a negative number.


They will all be negative, except for tinyint.
In most cases this shouldn't be a problem, unless you are using the sequence for generating surrogate keys and you have tied special meaning to some of them.

For example: 0 equals unknown, -1 equals not applicable.


A number is a number, it doesn't matter if it is negative or positive,
but when you do maintanance on table or you should copy and paste values to/from excel, great numbers
are annoying.
Post #1284732
Posted Tuesday, April 17, 2012 2:24 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 1:23 PM
Points: 977, Visits: 938
Thanks for the question

Iulian
Post #1284740
Posted Tuesday, April 17, 2012 2:33 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 4:31 AM
Points: 1,150, Visits: 1,089
Thanks for the question. I had to do a fair bit of digging to find out the answer.
Post #1284744
Posted Tuesday, April 17, 2012 2:54 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 3:20 AM
Points: 3,086, Visits: 3,283
Good question today, thanks - took an educated guess and got it wrong.

Looks like I need more education.


-------------------------------
Posting Data Etiquette - Jeff Moden
Smart way to ask a question

There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
Post #1284750
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse