SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sequences I


Sequences I

Author
Message
Schadenfreude-Mei
Schadenfreude-Mei
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3637 Visits: 1336
deleted due to embarrisment.

Adam Zacks

-------------------------------------------

Be Nice, Or Leave
Cliff Jones
Cliff Jones
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5191 Visits: 3648
Schadenfreude-Mei (4/17/2012)
Sorry guys but I took a guess, got it wrong so ran it through my local 2k8r2 and get the below:

Msg 343, Level 15, State 1, Line 1
Unknown object type 'SEQUENCE' used in a CREATE, DROP, or ALTER statement.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ';'.
Msg 343, Level 15, State 1, Line 5
Unknown object type 'SEQUENCE' used in CREATE, DROP, or ALTER statement.


SO what gives?

This feature requires SQL 2012.
jfogel-1131029
jfogel-1131029
Valued Member
Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)

Group: General Forum Members
Points: 57 Visits: 64
Yes, note the wording of the question.
sknox
sknox
Hall of Fame
Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)

Group: General Forum Members
Points: 3986 Visits: 2924
Schadenfreude-Mei (4/17/2012)
Sorry guys but I took a guess, got it wrong so ran it through my local 2k8r2 and get the below:

Msg 343, Level 15, State 1, Line 1
Unknown object type 'SEQUENCE' used in a CREATE, DROP, or ALTER statement.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ';'.
Msg 343, Level 15, State 1, Line 5
Unknown object type 'SEQUENCE' used in CREATE, DROP, or ALTER statement.


SO what gives?


From the question:
In a default installation of SQL Server 2012...


From the answer:
Sequences, a new feature in SQL Server 2012,...

Cliff Jones
Cliff Jones
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5191 Visits: 3648
Schadenfreude-Mei (4/17/2012)
deleted due to embarrisment.

Thanks, made me laugh. :-)
sknox
sknox
Hall of Fame
Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)

Group: General Forum Members
Points: 3986 Visits: 2924
Schadenfreude-Mei (4/17/2012)
deleted due to embarrisment.


We did kind of jump on you, didn't we? Rest assured it wasn't intended (I know when I wrote my post, the other two weren't there). We've all misread questions from time to time, and every once in a while, there actually is a poorly written question.

;-)
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)

Group: General Forum Members
Points: 65619 Visits: 18570
Nice question

Thanks



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

dick.baker
dick.baker
SSC-Enthusiastic
SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)

Group: General Forum Members
Points: 162 Visits: 91
for more info ..

-- #1 long numbers (Carlo doesn't like for Excel)
CREATE SEQUENCE SSC_ROCKS;
SELECT N0 = (NEXT VALUE FOR SSC_ROCKS); -- -9223372036854775808
SELECT N1 = (NEXT VALUE FOR SSC_ROCKS); -- -9223372036854775807
DROP SEQUENCE SSC_ROCKS;
GO

-- #2 try hex string instead
CREATE SEQUENCE SSC_ROCKX;
SELECT N0 = [sys].[fn_varbintohexstr](NEXT VALUE FOR SSC_ROCKX); -- 0x8000000000000000
SELECT N1 = [sys].[fn_varbintohexstr](NEXT VALUE FOR SSC_ROCKX); -- 0x8000000000000001
DROP SEQUENCE SSC_ROCKX;
GO

-- #3 show that ROLLBACK doesn't erase/reset sequence, ie behaves like IDENTITY()
CREATE SEQUENCE SSC_ROCKT;
begin tran
SELECT N0 = [sys].[fn_varbintohexstr](NEXT VALUE FOR SSC_ROCKT); -- 0x8000000000000000
SELECT N1 = [sys].[fn_varbintohexstr](NEXT VALUE FOR SSC_ROCKT); -- 0x8000000000000001
rollback
SELECT N2 = [sys].[fn_varbintohexstr](NEXT VALUE FOR SSC_ROCKT); -- 0x8000000000000002

DROP SEQUENCE SSC_ROCKT;
GO
Tom Thomson
Tom Thomson
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25737 Visits: 12494
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.

Only if they don't specify a negative increment (if they do, they will be positive).

Tom

Tom Thomson
Tom Thomson
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25737 Visits: 12494
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.

The CREATE SEQUENCE page in Bol gives an example in which the sequence is created by

CREATE SEQUENCE Test.TestSequence ;


so clearly MS thinks that not specifying any of those things works.

Tom

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search