Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sequences I


Sequences I

Author
Message
Schadenfreude-Mei
Schadenfreude-Mei
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

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

Adam Zacks

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

Be Nice, Or Leave
Cliff Jones
Cliff Jones
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4069 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
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 64
Yes, note the wording of the question.
sknox
sknox
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2030 Visits: 2709
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
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

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

Thanks, made me laugh. :-)
sknox
sknox
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2030 Visits: 2709
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-Insane
SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)

Group: General Forum Members
Points: 21071 Visits: 18259
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
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 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
TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10698 Visits: 11991
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

TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10698 Visits: 11991
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