<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dushyanth Jyothi &#187; DBCC CHECKIDENT</title>
	<atom:link href="http://dushi.co.uk/tag/dbcc-checkident/feed/" rel="self" type="application/rss+xml" />
	<link>http://dushi.co.uk</link>
	<description>Me, My Life and the Binary</description>
	<lastBuildDate>Thu, 22 Jul 2010 21:14:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Resetting/Changing the identity[auto-increment number] column value of a table</title>
		<link>http://dushi.co.uk/15/07/2009/resettingchanging-the-identityauto-increment-number-column-value-of-a-table/</link>
		<comments>http://dushi.co.uk/15/07/2009/resettingchanging-the-identityauto-increment-number-column-value-of-a-table/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 13:27:04 +0000</pubDate>
		<dc:creator>Dushyanth Jyothi</dc:creator>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[DBCC CHECKIDENT]]></category>
		<category><![CDATA[MS SERVER 2008]]></category>

		<guid isPermaLink="false">http://dushi.co.uk/?p=78</guid>
		<description><![CDATA[Resetting/Changing the identity[auto-increment number] column value of a tableDBCC CHECKIDENT checks the current identity value for the specified table and, if it is needed, changes the identity value. You can also use DBCC CHECKIDENT to manually set a new current identity value for the identity columnTested only on MS SERVER 2008Table to alter: &#160;T-SQL&#160;&#124;&#160;&#160;copy&#160;code&#160;&#124;?&#160;1CREATE TABLE [...]]]></description>
			<content:encoded><![CDATA[<strong>Resetting/Changing the identity[auto-increment number] column value of a table</strong><br /><br /><strong>DBCC CHECKIDENT</strong> checks the current identity value for the specified table and, if it is needed, changes the identity value. You can also use DBCC <strong>CHECKIDENT </strong>to manually set a new current identity value for the identity column<br /><br /><strong>Tested only on MS SERVER 2008</strong><br /><br /><strong>Table to alter: </strong><br /><br /><pre class="devcodeblock" title="T-SQL"><table class="devcodetools"><tbody><tr><td>&nbsp;T-SQL&nbsp;|&nbsp;</td><td style="background-image:url('http://dushi.co.uk/wp-content/plugins/devformatter/img/devformatter-copy.png');background-repeat:no-repeat;background-position:50% 50%;width:16px;height:16px;"/><embed id="ZeroClipboard3" src="http://dushi.co.uk/wp-content/plugins/devformatter/_zclipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16px" height="16px" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=3&width=16&height=16" wmode="transparent" /></td><td>&nbsp;copy&nbsp;code&nbsp;|</td><td style="cursor:pointer" title="DevFormatter Plugin" onclick="devfmt_credits()">?</td><td width="99%">&nbsp;</td></tr></tbody></table><div class="devcodeoverflow"><table class="devcodearea" width="100%"><tr><td class="devcodelines" width="1%">1</td><td class="devcodelinesarea"><pre class="devcode devcodeline"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> <span style="color: #0000FF;">ADMIN</span>.<span style="color: #202020;">DocumentType_List</span></pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">2</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"><span style="color: #808080;">&#40;</span></pre></td></tr><tr><td class="devcodelines" width="1%">3</td><td class="devcodelinesarea"><pre class="devcode devcodeline">	DocumentType_ID <span style="color: #0000FF;">INT</span> <span style="color: #0000FF;">IDENTITY</span><span style="color: #808080;">&#40;</span><span style="color: #000;">0</span>,<span style="color: #000;">1</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">NULL</span>,</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">4</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">	DocumentType <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">250</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">NULL</span>,</pre></td></tr><tr><td class="devcodelines" width="1%">5</td><td class="devcodelinesarea"><pre class="devcode devcodeline">	Description_ <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">250</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">NULL</span></pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">6</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"><span style="color: #0000FF;">CONSTRAINT</span> PK_DocumentType <span style="color: #0000FF;">PRIMARY</span> <span style="color: #0000FF;">KEY</span> <span style="color: #808080;">&#40;</span>DocumentType_ID<span style="color: #808080;">&#41;</span></pre></td></tr><tr><td class="devcodelines" width="1%">7</td><td class="devcodelinesarea"><pre class="devcode devcodeline"><span style="color: #808080;">&#41;</span></pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">8</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"></pre></td></tr></table></div></pre>
<br />In the above code 'DocumentType_ID' column has declared as Identity, having auto increment value by 1 starting with 0. This means the first row inserted will have 'DocumentType_ID' value of 1. then 2,3,so on..<br /><br />In future if we want to reset this value, for what so ever reason, we can use T-SQL:<br /><br /><pre class="devcodeblock" title="T-SQL"><table class="devcodetools"><tbody><tr><td>&nbsp;T-SQL&nbsp;|&nbsp;</td><td style="background-image:url('http://dushi.co.uk/wp-content/plugins/devformatter/img/devformatter-copy.png');background-repeat:no-repeat;background-position:50% 50%;width:16px;height:16px;"/><embed id="ZeroClipboard4" src="http://dushi.co.uk/wp-content/plugins/devformatter/_zclipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16px" height="16px" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=4&width=16&height=16" wmode="transparent" /></td><td>&nbsp;copy&nbsp;code&nbsp;|</td><td style="cursor:pointer" title="DevFormatter Plugin" onclick="devfmt_credits()">?</td><td width="99%">&nbsp;</td></tr></tbody></table><div class="devcodeoverflow"><table class="devcodearea" width="100%"><tr><td class="devcodelines" width="1%">1</td><td class="devcodelinesarea"><pre class="devcode devcodeline"></pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">2</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"><span style="color: #0000FF;">DBCC</span> CHECKIDENT<span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'Admin.DocumentType_List'</span>, RESEED, <span style="color: #000;">0</span><span style="color: #808080;">&#41;</span></pre></td></tr></table></div></pre>
<br />This code will reset table Identity back to 0.<br /> <br /><strong>Further Reading/Details:</strong><a href="http://msdn.microsoft.com/en-us/library/ms176057(SQL.90).aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ms176057(SQL.90).aspx</a>]]></content:encoded>
			<wfw:commentRss>http://dushi.co.uk/15/07/2009/resettingchanging-the-identityauto-increment-number-column-value-of-a-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
