<?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>ALTER COLUMN &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/alter-column/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Tue, 09 Oct 2018 20:00:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>SQL Server: Set IDENTITY to existing Column of a Table</title>
		<link>https://www.dbrnd.com/2019/01/sql-server-set-identity-to-existing-column-of-a-table/</link>
					<comments>https://www.dbrnd.com/2019/01/sql-server-set-identity-to-existing-column-of-a-table/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 07 Jan 2019 16:16:24 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[ALTER COLUMN]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Identity Column]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7389</guid>

					<description><![CDATA[Last week, I was exploring few SQL Server forums and found an interesting discussion on the IDENTITY Column of SQL Server. One of the discussions like How to set IDENTITY to existing column of a Table? Actually, there is no any specific option for setting IDENTITY to existing Column of a Table. But there are [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F01%2Fsql-server-set-identity-to-existing-column-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Set%20IDENTITY%20to%20existing%20Column%20of%20a%20Table" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F01%2Fsql-server-set-identity-to-existing-column-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Set%20IDENTITY%20to%20existing%20Column%20of%20a%20Table" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F01%2Fsql-server-set-identity-to-existing-column-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Set%20IDENTITY%20to%20existing%20Column%20of%20a%20Table" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F01%2Fsql-server-set-identity-to-existing-column-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Set%20IDENTITY%20to%20existing%20Column%20of%20a%20Table" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F01%2Fsql-server-set-identity-to-existing-column-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Set%20IDENTITY%20to%20existing%20Column%20of%20a%20Table" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F01%2Fsql-server-set-identity-to-existing-column-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Set%20IDENTITY%20to%20existing%20Column%20of%20a%20Table" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F01%2Fsql-server-set-identity-to-existing-column-of-a-table%2F&#038;title=SQL%20Server%3A%20Set%20IDENTITY%20to%20existing%20Column%20of%20a%20Table" data-a2a-url="https://www.dbrnd.com/2019/01/sql-server-set-identity-to-existing-column-of-a-table/" data-a2a-title="SQL Server: Set IDENTITY to existing Column of a Table"></a></p><p>Last week, I was exploring few SQL Server forums and found an interesting discussion on the IDENTITY Column of SQL Server.<br />
One of the discussions like How to set IDENTITY to existing column of a Table?</p>
<p>Actually, there is no any specific option for setting IDENTITY to existing Column of a Table.</p>
<p>But there are different tricks to do this, sharing one of the tricks here&#8230;</p>
<p><strong>Create a sample table without identity column:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_TestIdentity (ID INT, Name VARCHAR(10))

INSERT INTO tbl_TestIdentity VALUES 
(1,'ABC'), (2,'XYZ'),(3,'PQR')
,(4,'WER'),(5,'JKL'),(6,'ZXC')</pre> </p>
<p><strong>Check the data:</strong></p>
<pre class="crayon-plain-tag">SELECT *from tbl_TestIdentity

ID          Name
----------- ----------
1           ABC
2           XYZ
3           PQR
4           WER
5           JKL
6           ZXC</pre> </p>
<p><strong>Add new IDENTITY Column to table:</strong></p>
<pre class="crayon-plain-tag">ALTER TABLE tbl_TestIdentity ADD ID2 INT IDENTITY (1,1);</pre> </p>
<p><strong>Drop old ID Column:</strong></p>
<pre class="crayon-plain-tag">ALTER TABLE tbl_TestIdentity DROP COLUMN ID</pre> </p>
<p><strong>Rename new column to old column name:</strong></p>
<pre class="crayon-plain-tag">Exec sp_rename 'tbl_TestIdentity.ID2', 'ID', 'Column'</pre> </p>
<p><strong>Result:</strong></p>
<pre class="crayon-plain-tag">SELECT *from tbl_TestIdentity

Name       ID
---------- -----------
ABC        1
XYZ        2
PQR        3
WER        4
JKL        5
ZXC        6</pre> </p>
<blockquote class="wp-embedded-content" data-secret="kDApBclIAZ"><p><a href="https://www.dbrnd.com/2018/03/sql-server-how-to-remove-identity-from-a-column/">SQL Server: How to remove IDENTITY from a Column?</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2018/03/sql-server-how-to-remove-identity-from-a-column/embed/#?secret=kDApBclIAZ" data-secret="kDApBclIAZ" width="600" height="338" title="&#8220;SQL Server: How to remove IDENTITY from a Column?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote class="wp-embedded-content" data-secret="SARIxB3LJX"><p><a href="https://www.dbrnd.com/2015/12/sql-server-script-to-find-identity-column-of-a-database/">SQL Server: Script to find Identity Column of a Database</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/12/sql-server-script-to-find-identity-column-of-a-database/embed/#?secret=SARIxB3LJX" data-secret="SARIxB3LJX" width="600" height="338" title="&#8220;SQL Server: Script to find Identity Column of a Database&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/01/sql-server-set-identity-to-existing-column-of-a-table/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
