<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT &#8211; Retrieve Last Inserted Identity of Record</title>
	<atom:link href="http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Thu, 09 Feb 2012 19:36:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: wenyiwu</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-243057</link>
		<dc:creator><![CDATA[wenyiwu]]></dc:creator>
		<pubDate>Tue, 24 Jan 2012 15:20:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-243057</guid>
		<description><![CDATA[you are always able to explain concepts clearly. thank you so much for all your help.]]></description>
		<content:encoded><![CDATA[<p>you are always able to explain concepts clearly. thank you so much for all your help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-234491</link>
		<dc:creator><![CDATA[Josh]]></dc:creator>
		<pubDate>Mon, 09 Jan 2012 23:34:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-234491</guid>
		<description><![CDATA[Have you read about the bug with @@IDENTITY and SCOPE_IDENTITY():
https://connect.microsoft.com/SQLServer/feedback/details/328811/scope-identity-sometimes-returns-incorrect-value

If the comments are right, this bug isn&#039;t fixed until version 2012 comes out this year.]]></description>
		<content:encoded><![CDATA[<p>Have you read about the bug with @@IDENTITY and SCOPE_IDENTITY():<br />
<a href="https://connect.microsoft.com/SQLServer/feedback/details/328811/scope-identity-sometimes-returns-incorrect-value" rel="nofollow">https://connect.microsoft.com/SQLServer/feedback/details/328811/scope-identity-sometimes-returns-incorrect-value</a></p>
<p>If the comments are right, this bug isn&#8217;t fixed until version 2012 comes out this year.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Understanding Identity Beyond its Every Increasing Nature &#8211; Quiz &#8211; Puzzle &#8211; 3 of 31 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-230911</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Understanding Identity Beyond its Every Increasing Nature &#8211; Quiz &#8211; Puzzle &#8211; 3 of 31 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Wed, 04 Jan 2012 01:32:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-230911</guid>
		<description><![CDATA[[...] Server Interview Questions and Answers ISBN: 1466405643 Page#35 @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT – Retrieve Last Inserted Identity of Record Reseed Identity of Table – Table Missing Identity Values – Gap in Identity Column Discussion [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Server Interview Questions and Answers ISBN: 1466405643 Page#35 @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT – Retrieve Last Inserted Identity of Record Reseed Identity of Table – Table Missing Identity Values – Gap in Identity Column Discussion [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beatsoftech</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-213817</link>
		<dc:creator><![CDATA[beatsoftech]]></dc:creator>
		<pubDate>Fri, 09 Dec 2011 04:10:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-213817</guid>
		<description><![CDATA[hai yual,
            You can use ‘OUTPUT Inserted.UID as Prim_Key’ inside the insert query.Then return the Prim_Key value.]]></description>
		<content:encoded><![CDATA[<p>hai yual,<br />
            You can use ‘OUTPUT Inserted.UID as Prim_Key’ inside the insert query.Then return the Prim_Key value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beatsoftech</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-212800</link>
		<dc:creator><![CDATA[beatsoftech]]></dc:creator>
		<pubDate>Wed, 07 Dec 2011 14:21:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-212800</guid>
		<description><![CDATA[I just solved this problem by adding
                            &#039;OUTPUT Inserted.UID as Prim_Key&#039;
inside the insert query.......Any other method?????]]></description>
		<content:encoded><![CDATA[<p>I just solved this problem by adding<br />
                            &#8216;OUTPUT Inserted.UID as Prim_Key&#8217;<br />
inside the insert query&#8230;&#8230;.Any other method?????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Becky</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-211376</link>
		<dc:creator><![CDATA[Becky]]></dc:creator>
		<pubDate>Mon, 05 Dec 2011 14:19:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-211376</guid>
		<description><![CDATA[I&#039;m having trouble figuring out how to gather multiple ids from an insert into from select. I need to create a new revision of an item and the item is multirelated to another table and that table is multi-related to other tables, I need to gather the new ids and relate them to the old ids so I can make sure all the relationships are connecting correctly. Doing it 1 at a time would work with a cursor but I&#039;m trying avoid using a cursors.  I would apriciate any help. Thank You]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m having trouble figuring out how to gather multiple ids from an insert into from select. I need to create a new revision of an item and the item is multirelated to another table and that table is multi-related to other tables, I need to gather the new ids and relate them to the old ids so I can make sure all the relationships are connecting correctly. Doing it 1 at a time would work with a cursor but I&#8217;m trying avoid using a cursors.  I would apriciate any help. Thank You</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: justin</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-209301</link>
		<dc:creator><![CDATA[justin]]></dc:creator>
		<pubDate>Fri, 02 Dec 2011 11:22:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-209301</guid>
		<description><![CDATA[hi Pinal,
           In the case of  Uniqueidentifier ,returning empty from stored procedure while i am using @@IDENTITY or SCOPE_IDENTITY() for getting the primary key (which is unique identifier)of last inserted row.
Can you solve this problem?
Any other function available for retrieving the primary key value of last inserted row while using the uniqueidentifier type for primary key?]]></description>
		<content:encoded><![CDATA[<p>hi Pinal,<br />
           In the case of  Uniqueidentifier ,returning empty from stored procedure while i am using @@IDENTITY or SCOPE_IDENTITY() for getting the primary key (which is unique identifier)of last inserted row.<br />
Can you solve this problem?<br />
Any other function available for retrieving the primary key value of last inserted row while using the uniqueidentifier type for primary key?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: abhIShek online4all</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-177392</link>
		<dc:creator><![CDATA[abhIShek online4all]]></dc:creator>
		<pubDate>Tue, 11 Oct 2011 04:49:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-177392</guid>
		<description><![CDATA[Hi Pinal,

can you explain about  $IDENTITY, $ROWGUID,$action with example... 

Thanks,
abhIShek Online4all]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>can you explain about  $IDENTITY, $ROWGUID,$action with example&#8230; </p>
<p>Thanks,<br />
abhIShek Online4all</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sisir patro</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-175564</link>
		<dc:creator><![CDATA[sisir patro]]></dc:creator>
		<pubDate>Thu, 06 Oct 2011 06:05:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-175564</guid>
		<description><![CDATA[ALTER PROCEDURE [dbo].[REGISTER_USER]
	@username varchar(50),
	@password varchar(50),
	@bitfield bit,
	@fname varchar(50),
	@lname varchar(50)
AS
declare @role as varchar(50)
declare @fk int
BEGIN
	
	if(@bitfield = &#039;1&#039;)
	begin
	SET @role=&#039;Admin&#039;;
	insert into USER_INFO (UserName, Password, Role)values(@username, @password, @role);
	select @fk = USER_ID from USER_INFO where UserName=@username AND Password=@password;
	insert into ADMIN_DETAILS (User_id,Fname, Lname) values(@fk, @fname, @lname);
	select SCOPE_IDENTITY();
	select @@IDENTITY
	end
	if(@bitfield = &#039;0&#039;)
	begin
	SET @role=&#039;Guest&#039;;
	insert into USER_INFO (UserName, Password, Role)values(@username, @password, @role);
	select @fk = USER_ID from USER_INFO where UserName=@username AND Password=@password;
	insert into GUEST_DETAILS (User_id,Fname, Lname) values(@fk, @fname, @lname);
	select SCOPE_IDENTITY();
	select @@IDENTITY
	end

    -- Insert statements for procedure here
	
	
END


Here I want to return the scope identity of both USER_INFO and GUEST_DETAIL tables at a time.

 How is it possible by using the scope_identity() function.]]></description>
		<content:encoded><![CDATA[<p>ALTER PROCEDURE [dbo].[REGISTER_USER]<br />
	@username varchar(50),<br />
	@password varchar(50),<br />
	@bitfield bit,<br />
	@fname varchar(50),<br />
	@lname varchar(50)<br />
AS<br />
declare @role as varchar(50)<br />
declare @fk int<br />
BEGIN</p>
<p>	if(@bitfield = &#8217;1&#8242;)<br />
	begin<br />
	SET @role=&#8217;Admin&#8217;;<br />
	insert into USER_INFO (UserName, Password, Role)values(@username, @password, @role);<br />
	select @fk = USER_ID from USER_INFO where UserName=@username AND Password=@password;<br />
	insert into ADMIN_DETAILS (User_id,Fname, Lname) values(@fk, @fname, @lname);<br />
	select SCOPE_IDENTITY();<br />
	select @@IDENTITY<br />
	end<br />
	if(@bitfield = &#8217;0&#8242;)<br />
	begin<br />
	SET @role=&#8217;Guest&#8217;;<br />
	insert into USER_INFO (UserName, Password, Role)values(@username, @password, @role);<br />
	select @fk = USER_ID from USER_INFO where UserName=@username AND Password=@password;<br />
	insert into GUEST_DETAILS (User_id,Fname, Lname) values(@fk, @fname, @lname);<br />
	select SCOPE_IDENTITY();<br />
	select @@IDENTITY<br />
	end</p>
<p>    &#8212; Insert statements for procedure here</p>
<p>END</p>
<p>Here I want to return the scope identity of both USER_INFO and GUEST_DETAIL tables at a time.</p>
<p> How is it possible by using the scope_identity() function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-164684</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Fri, 02 Sep 2011 08:01:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-164684</guid>
		<description><![CDATA[There is no system function available for uniqueidentifier. You need to assign newid() value to a variable and use that variable to insert to a table. This is the only way you can keep tract of last uniqueidentifier]]></description>
		<content:encoded><![CDATA[<p>There is no system function available for uniqueidentifier. You need to assign newid() value to a variable and use that variable to insert to a table. This is the only way you can keep tract of last uniqueidentifier</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yucel</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-164037</link>
		<dc:creator><![CDATA[yucel]]></dc:creator>
		<pubDate>Wed, 31 Aug 2011 20:19:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-164037</guid>
		<description><![CDATA[if my identifier column type is uniqueidentifier, identity or scopeidentity wont work. What can i do?]]></description>
		<content:encoded><![CDATA[<p>if my identifier column type is uniqueidentifier, identity or scopeidentity wont work. What can i do?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Himadri</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-162630</link>
		<dc:creator><![CDATA[Himadri]]></dc:creator>
		<pubDate>Sat, 27 Aug 2011 13:03:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-162630</guid>
		<description><![CDATA[Nice Article]]></description>
		<content:encoded><![CDATA[<p>Nice Article</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rofiqul Islam</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-161331</link>
		<dc:creator><![CDATA[Rofiqul Islam]]></dc:creator>
		<pubDate>Wed, 24 Aug 2011 10:02:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-161331</guid>
		<description><![CDATA[It s a fine article. it will com to help of all level programmer
thanks]]></description>
		<content:encoded><![CDATA[<p>It s a fine article. it will com to help of all level programmer<br />
thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL LIon</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-159951</link>
		<dc:creator><![CDATA[SQL LIon]]></dc:creator>
		<pubDate>Sat, 20 Aug 2011 14:16:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-159951</guid>
		<description><![CDATA[All features of SQL Server IDENTITY property of columns. And a handy procedure to monitor all Identity columns.  http://www.sqllion.com/2011/08/identity-in-sql/]]></description>
		<content:encoded><![CDATA[<p>All features of SQL Server IDENTITY property of columns. And a handy procedure to monitor all Identity columns.  <a href="http://www.sqllion.com/2011/08/identity-in-sql/" rel="nofollow">http://www.sqllion.com/2011/08/identity-in-sql/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhu Gorthi</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-147464</link>
		<dc:creator><![CDATA[Madhu Gorthi]]></dc:creator>
		<pubDate>Mon, 11 Jul 2011 15:45:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-147464</guid>
		<description><![CDATA[janani, You can use OUTPUT clause in UPDATE staement which is a new feature added to SQL server version 2005 onwards. check this link for examples.
http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/]]></description>
		<content:encoded><![CDATA[<p>janani, You can use OUTPUT clause in UPDATE staement which is a new feature added to SQL server version 2005 onwards. check this link for examples.<br />
<a href="http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/" rel="nofollow">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-146919</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Fri, 08 Jul 2011 15:27:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-146919</guid>
		<description><![CDATA[You can have it via update trigger]]></description>
		<content:encoded><![CDATA[<p>You can have it via update trigger</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: janani</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-146824</link>
		<dc:creator><![CDATA[janani]]></dc:creator>
		<pubDate>Fri, 08 Jul 2011 06:03:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-146824</guid>
		<description><![CDATA[Hai Pinal,..
How to get Identity value of an Updated row in SQl?]]></description>
		<content:encoded><![CDATA[<p>Hai Pinal,..<br />
How to get Identity value of an Updated row in SQl?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Uday Satardekar</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-143358</link>
		<dc:creator><![CDATA[Uday Satardekar]]></dc:creator>
		<pubDate>Fri, 24 Jun 2011 06:32:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-143358</guid>
		<description><![CDATA[Hi 
I AM UDAY

I AM INSERTING BULK DATA USING XML IN SQL SERVER 2005.i AM USING C#.NET.

fOR SINGLE TABLE IT WORKS NICE BUT MY PROBLEM IS.I AM INSERTING IN TWO TABLES WITH RELATIONSHIP.MY TABLES ARE COMPANY AND EMAIL.

AND I AM TRYING TO SAVE COMPANY ID IN EMAIL TABLE.BUT IT RETURN ONLY LAST ID WHEN I AM INSERTING USING XML.HOW I CAN FIND @@IDENTITY FOR EACH ROW DURING XML INSERT.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



ALTER PROCEDURE [dbo].[insertDataUsngXml] 
	@XML_TRANSACTIONDETAILS XML
	


as
DECLARE  @i_Doc INT,
 @DataID int


BEGIN transaction
		EXEC SP_XML_PREPAREDOCUMENT @i_Doc OUTPUT,@XML_TRANSACTIONDETAILS
	    INSERT INTO tempdatainfo
                (
                   companyname,website,country,contactperson,telphone,mobile,fax,region,status,username,date,category,urlorcatalog
                )
                SELECT
               companyname,website,country,contactperson,telphone,mobile,fax,region,status,username,date,category,urlorcatalog
                 
                FROM OPENXML(@i_Doc,N&#039;master/TRANSACTION&#039;,2)

              WITH
              (
               companyname varchar(100),
				website varchar(100),
				country varchar(100),
				contactperson varchar(100),
				telphone varchar(100),
				mobile varchar(100),
				fax varchar(100),
				region varchar(100),
				status varchar(100),
				username varchar(100),
				date datetime,
				category varchar(100),
				urlorcatalog varchar(100),
				email varchar(100),
				email1 varchar(100)
               
              )

		SELECT @DataID=@@IDENTITY
	
                IF @@Error0 GOTO PROBLEM

		
		insert into tempemailinfo
		(
			DataID,email,category,status,region,username,date

		)
		SELECT
              @DataID, email,category,status,region,username,date
                 
                FROM OPENXML(@i_Doc,N&#039;master/TRANSACTION&#039;,2)

              WITH
              (
               
	status varchar(100),
	username varchar(100),
	date datetime,
	category varchar(100),
	urlorcatalog varchar(100),
	email varchar(100),
	email1 varchar(100),
     region varchar(100)



              )

		IF @@Error  0 GOTO PROBLEM


COMMIT TRANSACTION
    RETURN 0
    
    PROBLEM:
    ROLLBACK TRANSACTION
    RETURN 1




THANKS.]]></description>
		<content:encoded><![CDATA[<p>Hi<br />
I AM UDAY</p>
<p>I AM INSERTING BULK DATA USING XML IN SQL SERVER 2005.i AM USING C#.NET.</p>
<p>fOR SINGLE TABLE IT WORKS NICE BUT MY PROBLEM IS.I AM INSERTING IN TWO TABLES WITH RELATIONSHIP.MY TABLES ARE COMPANY AND EMAIL.</p>
<p>AND I AM TRYING TO SAVE COMPANY ID IN EMAIL TABLE.BUT IT RETURN ONLY LAST ID WHEN I AM INSERTING USING XML.HOW I CAN FIND @@IDENTITY FOR EACH ROW DURING XML INSERT.</p>
<p>set ANSI_NULLS ON<br />
set QUOTED_IDENTIFIER ON<br />
go</p>
<p>ALTER PROCEDURE [dbo].[insertDataUsngXml]<br />
	@XML_TRANSACTIONDETAILS XML</p>
<p>as<br />
DECLARE  @i_Doc INT,<br />
 @DataID int</p>
<p>BEGIN transaction<br />
		EXEC SP_XML_PREPAREDOCUMENT @i_Doc OUTPUT,@XML_TRANSACTIONDETAILS<br />
	    INSERT INTO tempdatainfo<br />
                (<br />
                   companyname,website,country,contactperson,telphone,mobile,fax,region,status,username,date,category,urlorcatalog<br />
                )<br />
                SELECT<br />
               companyname,website,country,contactperson,telphone,mobile,fax,region,status,username,date,category,urlorcatalog</p>
<p>                FROM OPENXML(@i_Doc,N&#8217;master/TRANSACTION&#8217;,2)</p>
<p>              WITH<br />
              (<br />
               companyname varchar(100),<br />
				website varchar(100),<br />
				country varchar(100),<br />
				contactperson varchar(100),<br />
				telphone varchar(100),<br />
				mobile varchar(100),<br />
				fax varchar(100),<br />
				region varchar(100),<br />
				status varchar(100),<br />
				username varchar(100),<br />
				date datetime,<br />
				category varchar(100),<br />
				urlorcatalog varchar(100),<br />
				email varchar(100),<br />
				email1 varchar(100)</p>
<p>              )</p>
<p>		SELECT @DataID=@@IDENTITY</p>
<p>                IF @@Error0 GOTO PROBLEM</p>
<p>		insert into tempemailinfo<br />
		(<br />
			DataID,email,category,status,region,username,date</p>
<p>		)<br />
		SELECT<br />
              @DataID, email,category,status,region,username,date</p>
<p>                FROM OPENXML(@i_Doc,N&#8217;master/TRANSACTION&#8217;,2)</p>
<p>              WITH<br />
              (</p>
<p>	status varchar(100),<br />
	username varchar(100),<br />
	date datetime,<br />
	category varchar(100),<br />
	urlorcatalog varchar(100),<br />
	email varchar(100),<br />
	email1 varchar(100),<br />
     region varchar(100)</p>
<p>              )</p>
<p>		IF @@Error  0 GOTO PROBLEM</p>
<p>COMMIT TRANSACTION<br />
    RETURN 0</p>
<p>    PROBLEM:<br />
    ROLLBACK TRANSACTION<br />
    RETURN 1</p>
<p>THANKS.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pathi</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-142436</link>
		<dc:creator><![CDATA[pathi]]></dc:creator>
		<pubDate>Mon, 20 Jun 2011 10:55:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-142436</guid>
		<description><![CDATA[Waht is the use of the @@IDENTITY in sql]]></description>
		<content:encoded><![CDATA[<p>Waht is the use of the @@IDENTITY in sql</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brijesh</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-139357</link>
		<dc:creator><![CDATA[Brijesh]]></dc:creator>
		<pubDate>Tue, 07 Jun 2011 04:22:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-139357</guid>
		<description><![CDATA[Hi Dave,

i m new to SQL server, i m stuck in the problem, i have to find max id based on department

eg:

e_id          e_dept
as123mk   MKT
as124mk   MKT
as125it     IT 
as126it     IT 

i m having 2 column e_id and e_dept which store employee id and employee department
in above table i have to find max id in MKT dept that is 124 and max id in IT dept that is 126.


Thanks in advance
 waiting for reply]]></description>
		<content:encoded><![CDATA[<p>Hi Dave,</p>
<p>i m new to SQL server, i m stuck in the problem, i have to find max id based on department</p>
<p>eg:</p>
<p>e_id          e_dept<br />
as123mk   MKT<br />
as124mk   MKT<br />
as125it     IT<br />
as126it     IT </p>
<p>i m having 2 column e_id and e_dept which store employee id and employee department<br />
in above table i have to find max id in MKT dept that is 124 and max id in IT dept that is 126.</p>
<p>Thanks in advance<br />
 waiting for reply</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Subir Sankar Das</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-138363</link>
		<dc:creator><![CDATA[Subir Sankar Das]]></dc:creator>
		<pubDate>Thu, 02 Jun 2011 09:15:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-138363</guid>
		<description><![CDATA[So nice pinal, can u please give some DR &amp; HA related topics in SQL DBA

Regards,

Subir]]></description>
		<content:encoded><![CDATA[<p>So nice pinal, can u please give some DR &amp; HA related topics in SQL DBA</p>
<p>Regards,</p>
<p>Subir</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alok Kumar Sharma</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-137726</link>
		<dc:creator><![CDATA[Alok Kumar Sharma]]></dc:creator>
		<pubDate>Tue, 31 May 2011 04:21:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-137726</guid>
		<description><![CDATA[Very Nice Pinal

Alok Kumar Sharma]]></description>
		<content:encoded><![CDATA[<p>Very Nice Pinal</p>
<p>Alok Kumar Sharma</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: India</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-135734</link>
		<dc:creator><![CDATA[India]]></dc:creator>
		<pubDate>Sat, 21 May 2011 00:44:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-135734</guid>
		<description><![CDATA[At last! Someone who unedsratdns! Thanks for posting!]]></description>
		<content:encoded><![CDATA[<p>At last! Someone who unedsratdns! Thanks for posting!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: taufique ahmed</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-133823</link>
		<dc:creator><![CDATA[taufique ahmed]]></dc:creator>
		<pubDate>Tue, 10 May 2011 13:20:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-133823</guid>
		<description><![CDATA[how to get the last inserted record in sql server]]></description>
		<content:encoded><![CDATA[<p>how to get the last inserted record in sql server</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gaurav Girdher</title>
		<link>http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-128259</link>
		<dc:creator><![CDATA[Gaurav Girdher]]></dc:creator>
		<pubDate>Mon, 11 Apr 2011 12:30:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/25/identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/#comment-128259</guid>
		<description><![CDATA[Hi Pinal,
Your article is just awesome.
I have a small query regarding the performance of the Three Clauses used above:
Can you please tell which one is better from performance point of view

@@IDENTITY / SCOPE_IDENTITY() / IDENT_CURRENT(&#039;tablename&#039;)

Waiting for your reply.

Regards
Gaurav Girdher]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
Your article is just awesome.<br />
I have a small query regarding the performance of the Three Clauses used above:<br />
Can you please tell which one is better from performance point of view</p>
<p>@@IDENTITY / SCOPE_IDENTITY() / IDENT_CURRENT(&#8216;tablename&#8217;)</p>
<p>Waiting for your reply.</p>
<p>Regards<br />
Gaurav Girdher</p>
]]></content:encoded>
	</item>
</channel>
</rss>

