<?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; MS SERVER 2008</title>
	<atom:link href="http://dushi.co.uk/tag/ms-server-2008/feed/" rel="self" type="application/rss+xml" />
	<link>http://dushi.co.uk</link>
	<description>Me, My Life and the Binary</description>
	<lastBuildDate>Sun, 18 Dec 2011 00:54:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<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 table DBCC 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 column Tested only on MS SERVER 2008 Table to [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Resetting/Changing the identity[auto-increment number] column value of a table</strong></p>
<p><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</p>
<p><strong>Tested only on MS SERVER 2008</strong></p>
<p><strong>Table to alter: </strong></p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><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>
<span style="color: #808080;">&#40;</span>
	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>,
	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>,
	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>
<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>
<span style="color: #808080;">&#41;</span></pre></div></div>

<p>In the above code &#8216;DocumentType_ID&#8217; column has declared as Identity, having auto increment value by 1 starting with 0. This means the first row inserted will have &#8216;DocumentType_ID&#8217; value of 1. then 2,3,so on..</p>
<p>In future if we want to reset this value, for what so ever reason, we can use T-SQL:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><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></div></div>

<p>This code will reset table Identity back to 0.</p>
<p><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></p>
]]></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>

