﻿<?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 Ben Kubicek  / What will the max id be? / 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>Thu, 23 May 2013 10:29:27 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>if we use delete instead of truncate reseed will not work...... the answer should be 4,8........:-P</description><pubDate>Mon, 21 Jan 2013 11:44:50 GMT</pubDate><dc:creator>manik123</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Good But Easy One.</description><pubDate>Tue, 15 Jan 2013 12:55:50 GMT</pubDate><dc:creator>asifkareem</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Easy one.</description><pubDate>Mon, 31 Dec 2012 05:31:49 GMT</pubDate><dc:creator>malleswarareddy_m</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Great question.</description><pubDate>Thu, 27 Dec 2012 13:34:54 GMT</pubDate><dc:creator>SanDroid</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>If you run all the lines in the question in a query window you will see you don't get an invalid object error.  The table doesn't get dropped before the selects are complete.</description><pubDate>Sat, 22 Dec 2012 06:11:06 GMT</pubDate><dc:creator>bkubicek</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>i think the answer will be "invalid object" as in last query we are dropping the table.</description><pubDate>Sat, 22 Dec 2012 01:24:23 GMT</pubDate><dc:creator>anamika.aashiyana17</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>i think the answer will be "invalid object" as in last query we are dropping the table.</description><pubDate>Sat, 22 Dec 2012 01:22:34 GMT</pubDate><dc:creator>anamika.aashiyana17</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Thanks for memorized .</description><pubDate>Thu, 20 Dec 2012 06:32:59 GMT</pubDate><dc:creator>Danny Ocean</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>from beginning............</description><pubDate>Thu, 20 Dec 2012 02:11:11 GMT</pubDate><dc:creator>udayroy15</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Good, straight-forward question on the basics. I'm surprised how many have gotten this wrong. I guess that means there are a lot of people learning a valuable point.</description><pubDate>Wed, 19 Dec 2012 20:47:46 GMT</pubDate><dc:creator>KWymore</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>It was easy, but really good for getting back to the basics. Thanks!</description><pubDate>Wed, 19 Dec 2012 12:06:40 GMT</pubDate><dc:creator>Revenant</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Thanks for the easy question.Saludos,</description><pubDate>Wed, 19 Dec 2012 10:37:58 GMT</pubDate><dc:creator>EL Jerry</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Weird, I was so sure I recently got a question wrong exactly because I thought truncate reseeded the identity and it actually didn't. Guess I was just confused. :-PThanks for the good question, apparently I really needed to learn that one.</description><pubDate>Wed, 19 Dec 2012 09:55:38 GMT</pubDate><dc:creator>Primo Dang</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Good Question, learned something today.</description><pubDate>Wed, 19 Dec 2012 08:04:52 GMT</pubDate><dc:creator>Mike Hays</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Hmm, I answered too quickly (being on holiday now), thinking that without specifying the column list, the INSERT would expect values for both columns and hence would fail the inserts (even though an identity insertion wouldn't be allowed either).  Doh.  Thanks for what should have been an easy one!</description><pubDate>Wed, 19 Dec 2012 07:29:19 GMT</pubDate><dc:creator>keith.fearnley</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Thanks for the easy one today.</description><pubDate>Wed, 19 Dec 2012 07:06:28 GMT</pubDate><dc:creator>Dana Medley</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>[quote][b]palotaiarpad (12/19/2012)[/b][hr]I'm also wrong, but i learned something. Could someone please explain, why is the identity resetted after a truncate? For me is a possible source of inconsitency.[/quote]Hello, if resetting the identity is a possible source of inconsistency you may try using DELETE instead of TRUNCATE.  DELETE will remove the data without resetting the identity.</description><pubDate>Wed, 19 Dec 2012 07:01:54 GMT</pubDate><dc:creator>Dave62</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>[quote][b]palotaiarpad (12/19/2012)[/b][hr]why is the identity resetted after a truncate? For me is a possible source of inconsitency.[/quote]As Lokesh has already explained, resetting the identity seed is a characteristic of the 'truncate' command.  If you want to retain the seed then you use 'delete' instead.   So, there's no inconsistency, it is just a case of using the right command according to your needs.At least you learnt something, so from that point of view it is a good question.  ;-)</description><pubDate>Wed, 19 Dec 2012 05:44:41 GMT</pubDate><dc:creator>Sean of the Lynchmob</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>[quote][b]SQL Kiwi (12/19/2012)[/b][hr]Another good one. 19% wrong right now :blink:[/quote]Yes, a good one.  And in the last 6 hours the wrong rate has grown from 19% to 27%, which seems rather high for such an easy question.</description><pubDate>Wed, 19 Dec 2012 05:30:56 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Easy one.. Remembering basics...</description><pubDate>Wed, 19 Dec 2012 05:05:08 GMT</pubDate><dc:creator>Dineshbabu</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>[quote][b]palotaiarpad (12/19/2012)[/b][hr]Could someone please explain, why is the identity resetted after a truncate?[/quote]Because conceptually, TRUNCATE TABLE is closer to DROP / CREATE than to DELETE.</description><pubDate>Wed, 19 Dec 2012 04:40:43 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Thanks for a nice easy Wednesday question.</description><pubDate>Wed, 19 Dec 2012 04:34:00 GMT</pubDate><dc:creator>(Bob Brown)  </dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>bcoz it is its behavior that every time we execute TRUNCATE command it will reset the identity value..</description><pubDate>Wed, 19 Dec 2012 04:03:08 GMT</pubDate><dc:creator>kapil_kk</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Good back-to-basics question, Thanks</description><pubDate>Wed, 19 Dec 2012 03:56:31 GMT</pubDate><dc:creator>Stewart "Arturius" Campbell</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>[quote][b]palotaiarpad (12/19/2012)[/b][hr] For me is a possible source of inconsitency.[/quote]Not sure why you said this as "inconsistency"...it's just the property of TRUNCATE command!</description><pubDate>Wed, 19 Dec 2012 03:28:12 GMT</pubDate><dc:creator>Lokesh Vij</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>[quote][b]palotaiarpad (12/19/2012)[/b][hr]I'm also wrong, but i learned something. Could someone please explain, why is the identity resetted after a truncate? For me is a possible source of inconsitency.[/quote]TRUNCATE command apart from removing data from the table, resets the seed value of the identity column defined in the table.Another command to re-seed identity is DBCC CHECKIDENT. It can be used something like below:[code="sql"]DBCC CHECKIDENT ('test_trun', RESEED, 0)[/code]</description><pubDate>Wed, 19 Dec 2012 03:26:06 GMT</pubDate><dc:creator>Lokesh Vij</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Nice question.Thanks</description><pubDate>Wed, 19 Dec 2012 02:46:02 GMT</pubDate><dc:creator>IgorMi</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>I'm also wrong, but i learned something. Could someone please explain, why is the identity resetted after a truncate? For me is a possible source of inconsitency.</description><pubDate>Wed, 19 Dec 2012 02:34:50 GMT</pubDate><dc:creator>palotaiarpad</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Another good one. 19% wrong right now :blink:</description><pubDate>Wed, 19 Dec 2012 00:11:43 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Easy one, thanks.</description><pubDate>Tue, 18 Dec 2012 23:56:42 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>easy ...truncate resets the identity;It's a coincidence , I was just discussing it with my colleague about inserting a row in between identity inserted column. And yes, Truncate popped up as an option :)</description><pubDate>Tue, 18 Dec 2012 23:20:58 GMT</pubDate><dc:creator>demonfox</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>easy one for Wednesday :-)revision of basics........</description><pubDate>Tue, 18 Dec 2012 23:00:25 GMT</pubDate><dc:creator>kapil_kk</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Thanks for reminding the basics :-)</description><pubDate>Tue, 18 Dec 2012 22:17:45 GMT</pubDate><dc:creator>Lokesh Vij</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>EZPZ</description><pubDate>Tue, 18 Dec 2012 21:24:39 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Nice back to basics question - thanks</description><pubDate>Tue, 18 Dec 2012 20:52:28 GMT</pubDate><dc:creator>bitbucket-25253</dc:creator></item><item><title>What will the max id be?</title><link>http://www.sqlservercentral.com/Forums/Topic1398128-2611-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/IDENTITY/95123/"&gt;What will the max id be?&lt;/A&gt;[/B]</description><pubDate>Tue, 18 Dec 2012 20:51:48 GMT</pubDate><dc:creator>bkubicek</dc:creator></item></channel></rss>