April 17, 2012 at 8:06 am
Thanks, learned something new.
----------------------------------------------------------------------------
Sacramento SQL Server users group - http://sac.sqlpass.org
Follow me on Twitter - @SQLDCH
----------------------------------------------------------------------------
April 17, 2012 at 8:07 am
jfogel (4/17/2012)
Got it right. It is nice to see the sequence feature is now in SQL Server. Mainly because developers had to use a sequence for Oracle and an identity column for SQL Server. At least now the code can move closer to being the same. Note I wrote closer.
Yes, I agree. After all these years it is good to see it being implemented in SQL Server.
April 17, 2012 at 8:56 am
tks for the questions - +1 for learned something new today. cheers
April 17, 2012 at 9:15 am
April 17, 2012 at 9:39 am
Thanks for the 2012 question. Keep 'em coming.
April 17, 2012 at 10:25 am
deleted due to embarrisment.
Adam Zacks-------------------------------------------Be Nice, Or Leave
April 17, 2012 at 10:27 am
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.
April 17, 2012 at 10:30 am
Yes, note the wording of the question.
April 17, 2012 at 10:30 am
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,...
April 17, 2012 at 12:53 pm
Schadenfreude-Mei (4/17/2012)
deleted due to embarrisment.
Thanks, made me laugh. 🙂
April 17, 2012 at 4:10 pm
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.
😉
April 17, 2012 at 9:44 pm
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[/url]
Learn Extended Events
April 18, 2012 at 1:33 am
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
April 18, 2012 at 1:27 pm
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
April 18, 2012 at 1:31 pm
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
Viewing 15 posts - 16 through 30 (of 36 total)
You must be logged in to reply to this topic. Login to reply