<?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; 2005 &#8211; OUTPUT Clause Example and Explanation with INSERT, UPDATE, DELETE</title>
	<atom:link href="http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Praveen Agrawal</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-54778</link>
		<dc:creator>Praveen Agrawal</dc:creator>
		<pubDate>Wed, 12 Aug 2009 11:40:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-54778</guid>
		<description>Hi Ajit,

 u can insert AutoID value to temp table, use following code,

--Creating a TestTable
CREATE TABLE TestTable (AutoID INT IDENTITY(1,1),ID INT, TEXTVal VARCHAR(100))
--Creating a Temp Table
DECLARE @TmpTable TABLE (AutoID INT,ID INT, TEXTVal VARCHAR(100))

--Insert  value in TestTable and get value in Temp Table 
INSERT TestTable (ID, TEXTVal)
OUTPUT Inserted.AutoID,Inserted.ID, Inserted.TEXTVal INTO @TmpTable
VALUES (1,&#039;FirstVal&#039;)

INSERT TestTable (ID, TEXTVal)
OUTPUT Inserted.AutoID,Inserted.ID, Inserted.TEXTVal INTO @TmpTable
VALUES (2,&#039;SecondVal&#039;)

select * from @TmpTable

AutoID	ID	TEXTVal
1	       1	 FirstVal
2	       2	SecondVal

--------------------------------------------------------------

we can&#039;t  Give The Autogenrate Column name in insert column, like insert TestTable(AutoID) that is wrong.


Thanks 

Praveen Agrawal</description>
		<content:encoded><![CDATA[<p>Hi Ajit,</p>
<p> u can insert AutoID value to temp table, use following code,</p>
<p>&#8211;Creating a TestTable<br />
CREATE TABLE TestTable (AutoID INT IDENTITY(1,1),ID INT, TEXTVal VARCHAR(100))<br />
&#8211;Creating a Temp Table<br />
DECLARE @TmpTable TABLE (AutoID INT,ID INT, TEXTVal VARCHAR(100))</p>
<p>&#8211;Insert  value in TestTable and get value in Temp Table<br />
INSERT TestTable (ID, TEXTVal)<br />
OUTPUT Inserted.AutoID,Inserted.ID, Inserted.TEXTVal INTO @TmpTable<br />
VALUES (1,&#8217;FirstVal&#8217;)</p>
<p>INSERT TestTable (ID, TEXTVal)<br />
OUTPUT Inserted.AutoID,Inserted.ID, Inserted.TEXTVal INTO @TmpTable<br />
VALUES (2,&#8217;SecondVal&#8217;)</p>
<p>select * from @TmpTable</p>
<p>AutoID	ID	TEXTVal<br />
1	       1	 FirstVal<br />
2	       2	SecondVal</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>we can&#8217;t  Give The Autogenrate Column name in insert column, like insert TestTable(AutoID) that is wrong.</p>
<p>Thanks </p>
<p>Praveen Agrawal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ajith</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-54053</link>
		<dc:creator>Ajith</dc:creator>
		<pubDate>Fri, 24 Jul 2009 08:03:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-54053</guid>
		<description>Hi ,
         We can&#039;t insert AutoID values to temp table? I tried following, but giving errors, 
-----------------------
CREATE TABLE TestTable (AutoID INT IDENTITY(1,1),ID INT, TEXTVal VARCHAR(100))
----Creating temp table to store ovalues of OUTPUT clause
DECLARE @TmpTable TABLE (AutoID INT,ID INT, TEXTVal VARCHAR(100))
----Insert values in real table as well use OUTPUT clause to insert
----values in the temp table.
INSERT TestTable (AutoID,ID, TEXTVal)
OUTPUT Inserted.AutoID,Inserted.ID, Inserted.TEXTVal INTO @TmpTable
VALUES (1,&#039;FirstVal&#039;)
INSERT TestTable (AutoID,ID, TEXTVal)
OUTPUT Inserted.AutoID,Inserted.ID, Inserted.TEXTVal INTO @TmpTable
VALUES (2,&#039;SecondVal&#039;)
----Check the values in the temp table and real table
----The values in both the tables will be same
SELECT * FROM @TmpTable
SELECT * FROM TestTable
----Clean up time
DROP TABLE TestTable
--------------------------

Thanks
Ajith</description>
		<content:encoded><![CDATA[<p>Hi ,<br />
         We can&#8217;t insert AutoID values to temp table? I tried following, but giving errors,<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
CREATE TABLE TestTable (AutoID INT IDENTITY(1,1),ID INT, TEXTVal VARCHAR(100))<br />
&#8212;-Creating temp table to store ovalues of OUTPUT clause<br />
DECLARE @TmpTable TABLE (AutoID INT,ID INT, TEXTVal VARCHAR(100))<br />
&#8212;-Insert values in real table as well use OUTPUT clause to insert<br />
&#8212;-values in the temp table.<br />
INSERT TestTable (AutoID,ID, TEXTVal)<br />
OUTPUT Inserted.AutoID,Inserted.ID, Inserted.TEXTVal INTO @TmpTable<br />
VALUES (1,&#8217;FirstVal&#8217;)<br />
INSERT TestTable (AutoID,ID, TEXTVal)<br />
OUTPUT Inserted.AutoID,Inserted.ID, Inserted.TEXTVal INTO @TmpTable<br />
VALUES (2,&#8217;SecondVal&#8217;)<br />
&#8212;-Check the values in the temp table and real table<br />
&#8212;-The values in both the tables will be same<br />
SELECT * FROM @TmpTable<br />
SELECT * FROM TestTable<br />
&#8212;-Clean up time<br />
DROP TABLE TestTable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Thanks<br />
Ajith</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ajith</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-54052</link>
		<dc:creator>Ajith</dc:creator>
		<pubDate>Fri, 24 Jul 2009 07:39:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-54052</guid>
		<description>Hi pinaldave,
         This is really good post. Can we use these things inside a transaction as well?
Thanks
Ajith</description>
		<content:encoded><![CDATA[<p>Hi pinaldave,<br />
         This is really good post. Can we use these things inside a transaction as well?<br />
Thanks<br />
Ajith</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - 2008 - SCOPE_IDENTITY Bug with Multi Processor Parallel Plan and Solution Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-49808</link>
		<dc:creator>SQL SERVER - 2008 - SCOPE_IDENTITY Bug with Multi Processor Parallel Plan and Solution Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Tue, 24 Mar 2009 01:32:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-49808</guid>
		<description>[...] clause: (Preferred Method) Refer my previous article for how to use OUTPUT clause information : SQL SERVER - 2005 - OUTPUT Clause Example and Explanation with INSERT, UPDATE, DELETE.I have included the same example along with this article for quick [...]</description>
		<content:encoded><![CDATA[<p>[...] clause: (Preferred Method) Refer my previous article for how to use OUTPUT clause information : SQL SERVER &#8211; 2005 &#8211; OUTPUT Clause Example and Explanation with INSERT, UPDATE, DELETE.I have included the same example along with this article for quick [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-47252</link>
		<dc:creator>SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Tue, 24 Feb 2009 12:11:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-47252</guid>
		<description>[...] SQL SERVER - 2005 - OUTPUT Clause Example and Explanation with INSERT, UPDATE, DELETE [...]</description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER &#8211; 2005 &#8211; OUTPUT Clause Example and Explanation with INSERT, UPDATE, DELETE [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todd M</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-46982</link>
		<dc:creator>Todd M</dc:creator>
		<pubDate>Fri, 20 Feb 2009 21:56:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-46982</guid>
		<description>Hi,
Thought I&#039;d ask an expert this question. I sometimes have the need to do deep-copies involving multiple tables where I need to maintain a mapping between IDs of rows being copied from and IDs of the new rows. I usually have to resort to doing the inserts one by one using cursors in order to maintain these mappings, but I thought the OUTPUT clause might allow me to do it in sets. But now I&#039;m not so sure I can get that &quot;from&quot; ID. Below is a simplification of what I&#039;d like to do:

INSERT Thing (Name)
OUTPUT Inserted.ID AS ToID, ??? AS FromID
SELECT Name
FROM Thing
WHERE ...

I can&#039;t get this to work because it seems that INSERTED columns are the only ones I can output, and hence I can&#039;t get the from ID. Can you confirm that this is correct? Thank you very much for your help.</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Thought I&#8217;d ask an expert this question. I sometimes have the need to do deep-copies involving multiple tables where I need to maintain a mapping between IDs of rows being copied from and IDs of the new rows. I usually have to resort to doing the inserts one by one using cursors in order to maintain these mappings, but I thought the OUTPUT clause might allow me to do it in sets. But now I&#8217;m not so sure I can get that &#8220;from&#8221; ID. Below is a simplification of what I&#8217;d like to do:</p>
<p>INSERT Thing (Name)<br />
OUTPUT Inserted.ID AS ToID, ??? AS FromID<br />
SELECT Name<br />
FROM Thing<br />
WHERE &#8230;</p>
<p>I can&#8217;t get this to work because it seems that INSERTED columns are the only ones I can output, and hence I can&#8217;t get the from ID. Can you confirm that this is correct? Thank you very much for your help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sameer</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-45068</link>
		<dc:creator>Sameer</dc:creator>
		<pubDate>Wed, 24 Dec 2008 21:07:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-45068</guid>
		<description>I mean copy dept1 in TABLE B</description>
		<content:encoded><![CDATA[<p>I mean copy dept1 in TABLE B</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sameer</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-45067</link>
		<dc:creator>Sameer</dc:creator>
		<pubDate>Wed, 24 Dec 2008 21:06:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-45067</guid>
		<description>Hi pinal,
I ejoy reading your blog as its neat and gives me a exact solution,

I am stumbled upon a small problem..

I have two tables which i want to update but the table B has a foreingn key in Table A which is Identity column,

Now if i do a single insert i am fine with output clause but how do i tackle a multiple insert.

Eg: table A Empid,Empname,deptid
table B, deptid,deptname,

now If i want to copy dept1 and insert into table B
Say dept1 has 100 employees,
My requirement is COPY the whole department with employees and create a duplicate dept in Table A
how do i do it. please help</description>
		<content:encoded><![CDATA[<p>Hi pinal,<br />
I ejoy reading your blog as its neat and gives me a exact solution,</p>
<p>I am stumbled upon a small problem..</p>
<p>I have two tables which i want to update but the table B has a foreingn key in Table A which is Identity column,</p>
<p>Now if i do a single insert i am fine with output clause but how do i tackle a multiple insert.</p>
<p>Eg: table A Empid,Empname,deptid<br />
table B, deptid,deptname,</p>
<p>now If i want to copy dept1 and insert into table B<br />
Say dept1 has 100 employees,<br />
My requirement is COPY the whole department with employees and create a duplicate dept in Table A<br />
how do i do it. please help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sukitha</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-45049</link>
		<dc:creator>Sukitha</dc:creator>
		<pubDate>Wed, 24 Dec 2008 05:12:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-45049</guid>
		<description>hi every one,
i need a help. i want to connect more than 30 database at the time to view the datails for the chairman of our group of company. if you know the coding please help me. 
thank you
Sukitha</description>
		<content:encoded><![CDATA[<p>hi every one,<br />
i need a help. i want to connect more than 30 database at the time to view the datails for the chairman of our group of company. if you know the coding please help me.<br />
thank you<br />
Sukitha</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Revathy Mani</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-41863</link>
		<dc:creator>Revathy Mani</dc:creator>
		<pubDate>Thu, 21 Aug 2008 08:33:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-41863</guid>
		<description>Create an history table &quot;table1&quot; to keep track the details of any changes in table &quot;table2&quot;

in this below example i am inserting the record into table &quot;table1&quot; when ever any insert or update is happened in &quot;table1&quot;

Create trigger [tg_Sample] on [dbo].[table1] for Insert,Update  as

Insert into table2 (col1,col2,col3,col4) 
select col1,col2,col3,col4 from inserted


This link will be helpfull to you...

http://msdn.microsoft.com/en-us/library/aa258254(SQL.80).aspx</description>
		<content:encoded><![CDATA[<p>Create an history table &#8220;table1&#8243; to keep track the details of any changes in table &#8220;table2&#8243;</p>
<p>in this below example i am inserting the record into table &#8220;table1&#8243; when ever any insert or update is happened in &#8220;table1&#8243;</p>
<p>Create trigger [tg_Sample] on [dbo].[table1] for Insert,Update  as</p>
<p>Insert into table2 (col1,col2,col3,col4)<br />
select col1,col2,col3,col4 from inserted</p>
<p>This link will be helpfull to you&#8230;</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa258254(SQL.80).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa258254(SQL.80).aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yasir</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-41693</link>
		<dc:creator>Yasir</dc:creator>
		<pubDate>Fri, 15 Aug 2008 02:03:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-41693</guid>
		<description>HI,


Can you please give one example to create Trigger on Row level and if there is any change in any field, insert the whole row in into the table.


Thanks,</description>
		<content:encoded><![CDATA[<p>HI,</p>
<p>Can you please give one example to create Trigger on Row level and if there is any change in any field, insert the whole row in into the table.</p>
<p>Thanks,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shyam</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-41571</link>
		<dc:creator>Shyam</dc:creator>
		<pubDate>Mon, 11 Aug 2008 09:06:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-41571</guid>
		<description>Hi Pinal,
Can we use Trigger in Sql server 2005 to perform:
1. Insert
2. Update
3. Delete
Processes with the FK. if yes.
Please give an example for that.

regards
shyam</description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
Can we use Trigger in Sql server 2005 to perform:<br />
1. Insert<br />
2. Update<br />
3. Delete<br />
Processes with the FK. if yes.<br />
Please give an example for that.</p>
<p>regards<br />
shyam</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-14645</link>
		<dc:creator>pinaldave</dc:creator>
		<pubDate>Wed, 03 Oct 2007 00:32:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-14645</guid>
		<description>Hi Ian MacLean,

I really do not understand your problem. Please clearify.

Regards,
Pinal Dave ( http://www.SQLAuthority.com )</description>
		<content:encoded><![CDATA[<p>Hi Ian MacLean,</p>
<p>I really do not understand your problem. Please clearify.</p>
<p>Regards,<br />
Pinal Dave ( <a href="http://www.SQLAuthority.com" rel="nofollow">http://www.SQLAuthority.com</a> )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian MacLean</title>
		<link>http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-14627</link>
		<dc:creator>Ian MacLean</dc:creator>
		<pubDate>Tue, 02 Oct 2007 15:05:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/#comment-14627</guid>
		<description>Hey. thanks for pointing this clause out. It would be very helpful, if it worked for me. I am coding in C# and every time i go to insert an item in the table, the code will fail if &quot;output inserted.*&quot; is in the command text. i&#039;ve tried moving around the clause as i&#039;ve seen on msdn. i didn&#039;t think that would help, and ... it didn&#039;t.

so, is there some special server configuration that i need? any helpful hints?</description>
		<content:encoded><![CDATA[<p>Hey. thanks for pointing this clause out. It would be very helpful, if it worked for me. I am coding in C# and every time i go to insert an item in the table, the code will fail if &#8220;output inserted.*&#8221; is in the command text. i&#8217;ve tried moving around the clause as i&#8217;ve seen on msdn. i didn&#8217;t think that would help, and &#8230; it didn&#8217;t.</p>
<p>so, is there some special server configuration that i need? any helpful hints?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
