<?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>IDENT_CURRENT &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/ident_current/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>Wed, 28 Feb 2018 03:26:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>SQL Server Interview: Difference between Sequence Object and Identity Column</title>
		<link>https://www.dbrnd.com/2018/03/sql-server-interview-difference-between-sequence-object-and-identity-column/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 08 Mar 2018 16:16:34 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[IDENT_CURRENT]]></category>
		<category><![CDATA[Identity Column]]></category>
		<category><![CDATA[SCOPE_IDENTITY]]></category>
		<category><![CDATA[Sequence object]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4287</guid>

					<description><![CDATA[This is a common interview question for SQL Server Database Developer. SQL Database Developer must prepare for this. Sequence and identity, both used to generate an auto number, but the major difference is Identity is a table dependant and Sequence is independent of a table. A Sequence Object introduced in SQL Server 2012 and Identity [&#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%2F2018%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" 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%2F2018%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" 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%2F2018%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" 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%2F2018%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" 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%2F2018%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" 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%2F2018%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" 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%2F2018%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&#038;title=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" data-a2a-url="https://www.dbrnd.com/2018/03/sql-server-interview-difference-between-sequence-object-and-identity-column/" data-a2a-title="SQL Server Interview: Difference between Sequence Object and Identity Column"></a></p><p>This is a common interview question for SQL Server Database Developer. SQL Database Developer must prepare for this.</p>
<p>Sequence and identity, both used to generate an auto number, but the major difference is Identity is a table dependant and Sequence is independent of a table.</p>
<blockquote><p>A Sequence Object introduced in SQL Server 2012 and Identity column introduced in SQL Server 6.0.</p></blockquote>
<blockquote><p>A Sequence is a User defined object and Identity column is a table property. </p></blockquote>
<blockquote><p> The same Sequence object can use with the multiple tables. The same Identity column cannot use with multiple tables, we can define identity column on each table individually. </p></blockquote>
<blockquote><p>If you define the same Sequence Object to multiple tables, it generates the sequence number database-wide and maintains a unique sequence number across the multiple tables. An Identity column generates a unique number at table only.</p></blockquote>
<blockquote><p>Sequence syntax (Start with 1 and Increment by 1):</p>
<pre class="crayon-plain-tag">CREATE SEQUENCE
  dbo.Sequence_Name AS INT
 START WITH 1
 INCREMENT BY 1
GO</pre> </p>
<p>Identity syntax (Start with 1 and Increment by 1):</p>
<pre class="crayon-plain-tag">CREATE TABLE dbo.Table_Name
( Id INT IDENTITY(1,1),
  Name VARCHAR(50) )
GO</pre>
</p></blockquote>
<blockquote><p>Check the next value of Sequence object:</p>
<pre class="crayon-plain-tag">SELECT (NEXT VALUE FOR dbo.Sequence_Name) AS SeqNextValue</pre> </p>
<p>Check the next value of Identity Column:</p>
<pre class="crayon-plain-tag">SELECT SCOPE_IDENTITY()</pre>
(write after use of Identity column)
</p></blockquote>
<blockquote><p>
Check the current value of Sequence Object:</p>
<pre class="crayon-plain-tag">SELECT Current_Value 
FROM Sys.Sequences 
WHERE name='Sequence_Name'</pre> </p>
<p>Check the current value of Identity Column:</p>
<pre class="crayon-plain-tag">SELECT IDENT_CURRENT('Table_Name') 
 AS 'IdentityCurrentValue'</pre>
</p></blockquote>
<blockquote><p>You can modify a Sequence object using ALTER Statement.</p>
<pre class="crayon-plain-tag">ALTER SEQUENCE dbo.Sequence_Name
RESTART WITH 100
INCREMENT BY 5
GO</pre> </p>
<p>You can only reset the value of an Identity column using DBCC CHECKIDENT().</p>
<pre class="crayon-plain-tag">DBCC CHECKIDENT('Table_Name', RESEED,100)</pre>
</p></blockquote>
<blockquote><p>In Sequence New values can be generated in an UPDATE statement, but in Identity new value cannot be generated in an UPDATE statement.</p></blockquote>
<blockquote><p>You can define a maximum value for Sequence Object (Using MAXVALUE). You cannot provide a maximum value to Identity Column.</p></blockquote>
<blockquote><p>Once your Sequence object reached to MAXVALUE, you can also define a CYCLE option to restart it from the beginning. You cannot restart an Identity column value.</p></blockquote>
<blockquote><p>You can also enable data CACHE for a Sequence Object. You cannot enable data CACHE for an Identity Column and it uses table related data cache. </p></blockquote>
<blockquote><p>A User must require an access permission for Sequence Object. For Identity column, User requires only table related permissions. </p></blockquote>
<blockquote><p>Performance wise, Identity column is 3x faster than Sequence object.</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Important difference between IDENT_CURRENT, @@IDENTITY and SCOPE_IDENTITY</title>
		<link>https://www.dbrnd.com/2016/09/sql-server-important-difference-between-ident_current-identity-and-scope_identity/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 27 Sep 2016 16:16:48 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[IDENT_CURRENT]]></category>
		<category><![CDATA[identity]]></category>
		<category><![CDATA[SCOPE_IDENTITY]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2079</guid>

					<description><![CDATA[I am sharing important difference between IDENT_CURRENT, @@IDENTITY and SCOPE_IDENTITY of the SQL Server. Generally, We are using this function to get last inserted identity value for further manipulation. There is a major difference between this function which is very important to know. IDENT_CURRENT: returns the last identity value generated for a specific table in [&#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%2F2016%2F09%2Fsql-server-important-difference-between-ident_current-identity-and-scope_identity%2F&amp;linkname=SQL%20Server%3A%20Important%20difference%20between%20IDENT_CURRENT%2C%20%40%40IDENTITY%20and%20SCOPE_IDENTITY" 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%2F2016%2F09%2Fsql-server-important-difference-between-ident_current-identity-and-scope_identity%2F&amp;linkname=SQL%20Server%3A%20Important%20difference%20between%20IDENT_CURRENT%2C%20%40%40IDENTITY%20and%20SCOPE_IDENTITY" 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%2F2016%2F09%2Fsql-server-important-difference-between-ident_current-identity-and-scope_identity%2F&amp;linkname=SQL%20Server%3A%20Important%20difference%20between%20IDENT_CURRENT%2C%20%40%40IDENTITY%20and%20SCOPE_IDENTITY" 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%2F2016%2F09%2Fsql-server-important-difference-between-ident_current-identity-and-scope_identity%2F&amp;linkname=SQL%20Server%3A%20Important%20difference%20between%20IDENT_CURRENT%2C%20%40%40IDENTITY%20and%20SCOPE_IDENTITY" 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%2F2016%2F09%2Fsql-server-important-difference-between-ident_current-identity-and-scope_identity%2F&amp;linkname=SQL%20Server%3A%20Important%20difference%20between%20IDENT_CURRENT%2C%20%40%40IDENTITY%20and%20SCOPE_IDENTITY" 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%2F2016%2F09%2Fsql-server-important-difference-between-ident_current-identity-and-scope_identity%2F&amp;linkname=SQL%20Server%3A%20Important%20difference%20between%20IDENT_CURRENT%2C%20%40%40IDENTITY%20and%20SCOPE_IDENTITY" 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%2F2016%2F09%2Fsql-server-important-difference-between-ident_current-identity-and-scope_identity%2F&#038;title=SQL%20Server%3A%20Important%20difference%20between%20IDENT_CURRENT%2C%20%40%40IDENTITY%20and%20SCOPE_IDENTITY" data-a2a-url="https://www.dbrnd.com/2016/09/sql-server-important-difference-between-ident_current-identity-and-scope_identity/" data-a2a-title="SQL Server: Important difference between IDENT_CURRENT, @@IDENTITY and SCOPE_IDENTITY"></a></p><p>I am sharing important difference between IDENT_CURRENT, @@IDENTITY and SCOPE_IDENTITY of the SQL Server. </p>
<p>Generally, We are using this function to get last inserted identity value for further manipulation.<br />
There is a major difference between this function which is very important to know. </p>
<blockquote><p><strong>IDENT_CURRENT:</strong> returns the last identity value generated for a specific table in any session and any scope.</p></blockquote>
<blockquote><p>
<strong>@@IDENTITY:</strong> returns the last identity value generated for any table in the current session, across all scopes.<br />
We should use this carefully because it is not limited to a specific scope and you might be getting last identity value from a trigger instead of your current statement. </p></blockquote>
<blockquote>
<p><strong>SCOPE_IDENTITY: </strong>returns the last identity value generated for any table in the current session and the current scope.</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
