﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by sknox  / Sequences I / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 22 May 2013 08:40:10 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Before answering referred BOL many times, so i got it correct..</description><pubDate>Wed, 09 Jan 2013 06:30:22 GMT</pubDate><dc:creator>Dineshbabu</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>I don't have 2012 yet , I went through msdn [url]http://msdn.microsoft.com/en-us/library/ff878091.aspx[/url]I thought the answer would be min(bigint)+1 ; and that wasn't listed ; didn't understand the defaults ..guess need to dig out more..</description><pubDate>Fri, 03 Aug 2012 05:46:19 GMT</pubDate><dc:creator>demonfox</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>[quote][b]Britt Cluff (4/23/2012)[/b][hr]Good question on a new feature. Thanks for submitting.[/quote] +1</description><pubDate>Mon, 21 May 2012 02:21:40 GMT</pubDate><dc:creator>Hardy21</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Good question on a new feature. Thanks for submitting.</description><pubDate>Mon, 23 Apr 2012 20:19:56 GMT</pubDate><dc:creator>Britt Cluff</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Nice question. Got it wrong and learned something in the process :) And sequences will be SQL 2012 exam questions so this is a great help.</description><pubDate>Thu, 19 Apr 2012 21:30:59 GMT</pubDate><dc:creator>andy mack</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>I chose "1" as the default start value because I thought it would have the same behaviour of the IDENTITY property which defaults to "start with 1, increment 1". Seems I must study more closely this welcome new feature.That means one less problem converting code to/from Oracle. :-)</description><pubDate>Wed, 18 Apr 2012 21:06:05 GMT</pubDate><dc:creator>codebyo</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Nice question.  It's good to see some SQL 2012 stuff now and again.I saw 0, 1, min(int), min(bigint) presented as options and decided I would have to find it in BoL; obviously if it had been a methematician who designed it I could forget about 1, but 0 was maybe possible (although far from optimal) and the thing would probably have type-flexibility (to cater for very long sequences when needed at the same time as allowing small numbers when vl sequences weren't needed) but that flexibility meant that the choice of which type would be default wasn't really constrained beyond the requirement for an integer type.  So I had to find it in BoL instead of being able to guess the answer by applying common sense, which meant I did some useful reading again, which in turn meant that I thought it was a good question.</description><pubDate>Wed, 18 Apr 2012 13:44:13 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>[quote][b]Henrico Bekker (4/16/2012)[/b][hr]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.[/quote]The CREATE SEQUENCE page in Bol gives an example in which the sequence is created by [code]CREATE SEQUENCE Test.TestSequence ;[/code]so clearly MS thinks that not specifying any of those things works.</description><pubDate>Wed, 18 Apr 2012 13:31:22 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>[quote][b]Koen Verbeeck (4/17/2012)[/b][hr][quote][b]Carlo Romagnano (4/17/2012)[/b][hr]I am curious to know how many developpers will use default value for "START WITH". In most cases will be a negative number.[/quote]They will all be negative, except for tinyint.[/quote]Only if they don't specify a negative increment (if they do, they will be positive).</description><pubDate>Wed, 18 Apr 2012 13:27:39 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>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);  -- -9223372036854775807DROP SEQUENCE SSC_ROCKS;GO-- #2 try hex string insteadCREATE SEQUENCE SSC_ROCKX;  SELECT N0 = [sys].[fn_varbintohexstr](NEXT VALUE FOR SSC_ROCKX);  -- 0x8000000000000000  SELECT N1 = [sys].[fn_varbintohexstr](NEXT VALUE FOR SSC_ROCKX);  -- 0x8000000000000001DROP 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);  -- 0x8000000000000001rollbackSELECT N2 = [sys].[fn_varbintohexstr](NEXT VALUE FOR SSC_ROCKT);  -- 0x8000000000000002DROP SEQUENCE SSC_ROCKT;GO</description><pubDate>Wed, 18 Apr 2012 01:33:24 GMT</pubDate><dc:creator>dick.baker</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Nice questionThanks</description><pubDate>Tue, 17 Apr 2012 21:44:39 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>[quote][b]Schadenfreude-Mei (4/17/2012)[/b][hr]deleted due to embarrisment.[/quote]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. ;-)</description><pubDate>Tue, 17 Apr 2012 16:10:54 GMT</pubDate><dc:creator>sknox</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>[quote][b]Schadenfreude-Mei (4/17/2012)[/b][hr]deleted due to embarrisment.[/quote]Thanks, made me laugh. :-)</description><pubDate>Tue, 17 Apr 2012 12:53:30 GMT</pubDate><dc:creator>Cliff Jones</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>[quote][b]Schadenfreude-Mei (4/17/2012)[/b][hr]Sorry guys but I took a guess, got it wrong so ran it through my local 2k8r2 and get the below:[quote]Msg 343, Level 15, State 1, Line 1Unknown object type 'SEQUENCE' used in a CREATE, DROP, or ALTER statement.Msg 102, Level 15, State 1, Line 3Incorrect syntax near ';'.Msg 343, Level 15, State 1, Line 5Unknown object type 'SEQUENCE' used in  CREATE, DROP, or ALTER statement.[/quote]SO what gives?[/quote]From the question: [quote]In a default installation of SQL Server 2012...[/quote]From the answer:[quote]Sequences, a new feature in SQL Server 2012,...[/quote]</description><pubDate>Tue, 17 Apr 2012 10:30:53 GMT</pubDate><dc:creator>sknox</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Yes, note the wording of the question.</description><pubDate>Tue, 17 Apr 2012 10:30:20 GMT</pubDate><dc:creator>jfogel-1131029</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>[quote][b]Schadenfreude-Mei (4/17/2012)[/b][hr]Sorry guys but I took a guess, got it wrong so ran it through my local 2k8r2 and get the below:[quote]Msg 343, Level 15, State 1, Line 1Unknown object type 'SEQUENCE' used in a CREATE, DROP, or ALTER statement.Msg 102, Level 15, State 1, Line 3Incorrect syntax near ';'.Msg 343, Level 15, State 1, Line 5Unknown object type 'SEQUENCE' used in  CREATE, DROP, or ALTER statement.[/quote]SO what gives?[/quote]This feature requires SQL 2012.</description><pubDate>Tue, 17 Apr 2012 10:27:43 GMT</pubDate><dc:creator>Cliff Jones</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>deleted due to embarrisment.</description><pubDate>Tue, 17 Apr 2012 10:25:14 GMT</pubDate><dc:creator>Schadenfreude-Mei</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Thanks for the 2012 question. Keep 'em coming.</description><pubDate>Tue, 17 Apr 2012 09:39:51 GMT</pubDate><dc:creator>KWymore</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Good one. Good to know since I still don't have access to SQL Server 2012, but eventually will."El" Jerry.</description><pubDate>Tue, 17 Apr 2012 09:15:18 GMT</pubDate><dc:creator>EL Jerry</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>tks for the questions - +1 for learned something new today.  cheers</description><pubDate>Tue, 17 Apr 2012 08:56:30 GMT</pubDate><dc:creator>OzYbOi d(-_-)b</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>[quote][b]jfogel (4/17/2012)[/b][hr]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.[/quote]Yes, I agree.  After all these years it is good to see it being implemented in SQL Server.</description><pubDate>Tue, 17 Apr 2012 08:07:54 GMT</pubDate><dc:creator>Cliff Jones</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Thanks, learned something new.</description><pubDate>Tue, 17 Apr 2012 08:06:08 GMT</pubDate><dc:creator>SQLDCH</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>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.</description><pubDate>Tue, 17 Apr 2012 07:11:15 GMT</pubDate><dc:creator>jfogel</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Great question. Simple (with a single look at BOL), clear cut, a bit surprising, and on a new version. Thanks!</description><pubDate>Tue, 17 Apr 2012 05:32:58 GMT</pubDate><dc:creator>Thomas Abraham</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>A great questions, got me thinking so well worth it.Thank you.</description><pubDate>Tue, 17 Apr 2012 04:39:07 GMT</pubDate><dc:creator>Nic-306421</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>[quote][b]DugyC (4/17/2012)[/b][hr]At first thought it wasn't fair to ask a SQL 2012 question as its so new...[/quote]Hold on to yourself, because it's a SSIS 2012 question tomorrow :-D</description><pubDate>Tue, 17 Apr 2012 03:01:01 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Great question, and a nice feature to know about... not sure what I'd use it for mind.At first thought it wasn't fair to ask a SQL 2012 question as its so new, but bit my lip and did a wee bit of research and the answer was there in a flash.Relatively easy question come the end.Cheers for the point. :-)</description><pubDate>Tue, 17 Apr 2012 02:58:09 GMT</pubDate><dc:creator>DugyC</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Good question today, thanks - took an educated guess and got it wrong.Looks like I need more education.</description><pubDate>Tue, 17 Apr 2012 02:54:25 GMT</pubDate><dc:creator>Stuart Davies</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Thanks for the question. I had to do a fair bit of digging to find out the answer.</description><pubDate>Tue, 17 Apr 2012 02:33:12 GMT</pubDate><dc:creator>Michael Lysons</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Thanks for the questionIulian</description><pubDate>Tue, 17 Apr 2012 02:24:15 GMT</pubDate><dc:creator>Iulian -207023</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>[quote][b]Koen Verbeeck (4/17/2012)[/b][hr][quote][b]Carlo Romagnano (4/17/2012)[/b][hr]I am curious to know how many developpers will use default value for "START WITH". In most cases will be a negative number.[/quote]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.[/quote]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 numbersare annoying.</description><pubDate>Tue, 17 Apr 2012 02:06:47 GMT</pubDate><dc:creator>Carlo Romagnano</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>[quote][b]Carlo Romagnano (4/17/2012)[/b][hr]I am curious to know how many developpers will use default value for "START WITH". In most cases will be a negative number.[/quote]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.</description><pubDate>Tue, 17 Apr 2012 01:21:58 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>I am curious to know how many developpers will use default value for "START WITH". In most cases will be a negative number.</description><pubDate>Tue, 17 Apr 2012 01:17:59 GMT</pubDate><dc:creator>Carlo Romagnano</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Interesting question, thanks...</description><pubDate>Tue, 17 Apr 2012 00:42:54 GMT</pubDate><dc:creator>Stewart "Arturius" Campbell</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>[quote][b]Henrico Bekker (4/16/2012)[/b][hr]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.[/quote]When I look at BOL I see the following:[quote]CREATE SEQUENCE [schema_name . ] sequence_name    [ AS [ built_in_integer_type | user-defined_integer_type ] ]    [ START WITH &amp;lt;constant&amp;gt; ]    [ INCREMENT BY &amp;lt;constant&amp;gt; ]    [ { MINVALUE [ &amp;lt;constant&amp;gt; ] } | { NO MINVALUE } ]    [ { MAXVALUE [ &amp;lt;constant&amp;gt; ] } | { NO MAXVALUE } ]    [ CYCLE | { NO CYCLE } ]    [ { CACHE [ &amp;lt;constant&amp;gt; ] } | { NO CACHE } ]    [ ; ][/quote]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!</description><pubDate>Tue, 17 Apr 2012 00:41:54 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>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.</description><pubDate>Mon, 16 Apr 2012 22:28:48 GMT</pubDate><dc:creator>Henrico Bekker</dc:creator></item><item><title>Sequences I</title><link>http://www.sqlservercentral.com/Forums/Topic1284658-2794-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/T-SQL/89565/"&gt;Sequences I&lt;/A&gt;[/B]</description><pubDate>Mon, 16 Apr 2012 22:27:47 GMT</pubDate><dc:creator>sknox</dc:creator></item></channel></rss>