<?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; Insert Data From One Table to Another Table &#8211; INSERT INTO SELECT &#8211; SELECT INTO TABLE</title>
	<atom:link href="http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/</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: Tejas Shah</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57634</link>
		<dc:creator>Tejas Shah</dc:creator>
		<pubDate>Mon, 16 Nov 2009 10:36:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57634</guid>
		<description>Hi Ehsan,

You can do this as:

--Insert code
INSERT INTO TableA(columns)
SELECT Columns
FROM TableB b
WHERE NOT EXISTS(
SELECT a.Id
FROM TableA a 
WHERE a.ID = b.ID
)

--Update code
UPDATE TableA
SET Columns = b.Columns
FROM TableA a
INNER JOIN TableB b ON a.ID = b.ID

Let me know if you have any questions.

Tejas
SQLYoga</description>
		<content:encoded><![CDATA[<p>Hi Ehsan,</p>
<p>You can do this as:</p>
<p>&#8211;Insert code<br />
INSERT INTO TableA(columns)<br />
SELECT Columns<br />
FROM TableB b<br />
WHERE NOT EXISTS(<br />
SELECT a.Id<br />
FROM TableA a<br />
WHERE a.ID = b.ID<br />
)</p>
<p>&#8211;Update code<br />
UPDATE TableA<br />
SET Columns = b.Columns<br />
FROM TableA a<br />
INNER JOIN TableB b ON a.ID = b.ID</p>
<p>Let me know if you have any questions.</p>
<p>Tejas<br />
SQLYoga</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57618</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Sun, 15 Nov 2009 05:47:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57618</guid>
		<description>@Ehsan.

What is the concern. You explained your scenario. But what is that you want from us.

You want us to write a script for you or are you looking for any solution from us on how you can implement your requirement.

Please briefly tell us what is that you want us to do ? what kind of help you are looking for.

~ IM</description>
		<content:encoded><![CDATA[<p>@Ehsan.</p>
<p>What is the concern. You explained your scenario. But what is that you want from us.</p>
<p>You want us to write a script for you or are you looking for any solution from us on how you can implement your requirement.</p>
<p>Please briefly tell us what is that you want us to do ? what kind of help you are looking for.</p>
<p>~ IM</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ehsan</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57613</link>
		<dc:creator>Ehsan</dc:creator>
		<pubDate>Sat, 14 Nov 2009 12:03:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57613</guid>
		<description>i have to same database with exactly same tables!
i want to add data from DB A into DB B.
i want to check if the primary key of a table in DB A doesn&#039;t exist on DB B insert that record else update that record!

help me !</description>
		<content:encoded><![CDATA[<p>i have to same database with exactly same tables!<br />
i want to add data from DB A into DB B.<br />
i want to check if the primary key of a table in DB A doesn&#8217;t exist on DB B insert that record else update that record!</p>
<p>help me !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57571</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Fri, 13 Nov 2009 01:28:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57571</guid>
		<description>@Sneha.

I am not aware of any direct way of doing this. 

You could do this from SQL Server Management studio easily, but if you see Generate Script for this, you would see that 
1. Your original table is copied into a temp table, 
2. Original table is dropped and 
3. A new table is created with column added with the specified column location and 
4. Then data is copied from temporary table to this new table. 
5. And then name of this new table will be renamed to your original table.

~ IM.</description>
		<content:encoded><![CDATA[<p>@Sneha.</p>
<p>I am not aware of any direct way of doing this. </p>
<p>You could do this from SQL Server Management studio easily, but if you see Generate Script for this, you would see that<br />
1. Your original table is copied into a temp table,<br />
2. Original table is dropped and<br />
3. A new table is created with column added with the specified column location and<br />
4. Then data is copied from temporary table to this new table.<br />
5. And then name of this new table will be renamed to your original table.</p>
<p>~ IM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sneha</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57531</link>
		<dc:creator>Sneha</dc:creator>
		<pubDate>Thu, 12 Nov 2009 03:17:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57531</guid>
		<description>Hi,

I wanted to know the alter command to add a column in middle of other columns in existing table.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I wanted to know the alter command to add a column in middle of other columns in existing table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jignesh Kyada</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57488</link>
		<dc:creator>Jignesh Kyada</dc:creator>
		<pubDate>Tue, 10 Nov 2009 12:03:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57488</guid>
		<description>Dear All,

can anybody have answer of how to swap data from one identity column to same column in sql server 2005 table</description>
		<content:encoded><![CDATA[<p>Dear All,</p>
<p>can anybody have answer of how to swap data from one identity column to same column in sql server 2005 table</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ania</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57250</link>
		<dc:creator>Ania</dc:creator>
		<pubDate>Mon, 02 Nov 2009 02:11:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57250</guid>
		<description>Thanks so much, the first useful bulk insert article!
;)</description>
		<content:encoded><![CDATA[<p>Thanks so much, the first useful bulk insert article!<br />
;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harish</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57076</link>
		<dc:creator>Harish</dc:creator>
		<pubDate>Tue, 27 Oct 2009 13:41:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57076</guid>
		<description>Thanks Brian, for your time and effort, i&#039;ll re-look into my stored proc and try to make it simple as you suggested...

Thanks again,

Harish</description>
		<content:encoded><![CDATA[<p>Thanks Brian, for your time and effort, i&#8217;ll re-look into my stored proc and try to make it simple as you suggested&#8230;</p>
<p>Thanks again,</p>
<p>Harish</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57074</link>
		<dc:creator>Brian Tkatch</dc:creator>
		<pubDate>Tue, 27 Oct 2009 13:26:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57074</guid>
		<description>@Harish

I&#039;m happy you could figure it out.

I always try making it one query if possible. I could not see it here, because a PROCEDURE is being used in the middle.

INSERT...SELECT is usually faster than a CURSOR. And as one query, everything will be in context too. And for many, it is much easier to read because all the logic is in one statement. It might be worth a bit of your time to review the entire process and see if it can be one statement.</description>
		<content:encoded><![CDATA[<p>@Harish</p>
<p>I&#8217;m happy you could figure it out.</p>
<p>I always try making it one query if possible. I could not see it here, because a PROCEDURE is being used in the middle.</p>
<p>INSERT&#8230;SELECT is usually faster than a CURSOR. And as one query, everything will be in context too. And for many, it is much easier to read because all the logic is in one statement. It might be worth a bit of your time to review the entire process and see if it can be one statement.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harish</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57049</link>
		<dc:creator>Harish</dc:creator>
		<pubDate>Mon, 26 Oct 2009 20:59:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57049</guid>
		<description>@Brian, hmm i dont think so. But i was able to figure out my issue. 

The correct one&#039;s is:

	DECLARE @MyCursor1 CURSOR
	SET @MyCursor1 = CURSOR FAST_FORWARD
	FOR		
	SELECT strength_app_men_inst_id from TACF_WFTA_STRENGTH_APP_MEN_INST where wf_task_assignment_id = @WfTaskAssignmentIDP1 			
	OPEN @MyCursor1
	FETCH NEXT FROM @MyCursor1 INTO @strength_app_men_inst_id
	WHILE @@FETCH_STATUS = 0
	BEGIN				
		exec @ReturnCode = getid_sel @table = &#039;TACF_WFTA_STRENGTH_APP_MEN_INST&#039;, @id = @NewID2 OUTPUT, @mode = 2
		insert into TACF_WFTA_STRENGTH_APP_MEN_INST (id, wf_task_assignment_id, strength_app_men_inst_id) values (@NewID2, @WfTaskAssignmentIDP2, @strength_app_men_inst_id)			
		FETCH NEXT FROM @MyCursor1 INTO @strength_app_men_inst_id									
	END
	CLOSE @MyCursor1
	DEALLOCATE @MyCursor1	




Thanks for checking out... Harish</description>
		<content:encoded><![CDATA[<p>@Brian, hmm i dont think so. But i was able to figure out my issue. </p>
<p>The correct one&#8217;s is:</p>
<p>	DECLARE @MyCursor1 CURSOR<br />
	SET @MyCursor1 = CURSOR FAST_FORWARD<br />
	FOR<br />
	SELECT strength_app_men_inst_id from TACF_WFTA_STRENGTH_APP_MEN_INST where wf_task_assignment_id = @WfTaskAssignmentIDP1<br />
	OPEN @MyCursor1<br />
	FETCH NEXT FROM @MyCursor1 INTO @strength_app_men_inst_id<br />
	WHILE @@FETCH_STATUS = 0<br />
	BEGIN<br />
		exec @ReturnCode = getid_sel @table = &#8216;TACF_WFTA_STRENGTH_APP_MEN_INST&#8217;, @id = @NewID2 OUTPUT, @mode = 2<br />
		insert into TACF_WFTA_STRENGTH_APP_MEN_INST (id, wf_task_assignment_id, strength_app_men_inst_id) values (@NewID2, @WfTaskAssignmentIDP2, @strength_app_men_inst_id)<br />
		FETCH NEXT FROM @MyCursor1 INTO @strength_app_men_inst_id<br />
	END<br />
	CLOSE @MyCursor1<br />
	DEALLOCATE @MyCursor1	</p>
<p>Thanks for checking out&#8230; Harish</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57038</link>
		<dc:creator>Brian Tkatch</dc:creator>
		<pubDate>Mon, 26 Oct 2009 15:07:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57038</guid>
		<description>@Harish

Is there a way top combine this into one statement?

INSERT INTO .... SELECT ... FROM</description>
		<content:encoded><![CDATA[<p>@Harish</p>
<p>Is there a way top combine this into one statement?</p>
<p>INSERT INTO &#8230;. SELECT &#8230; FROM</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harish</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57018</link>
		<dc:creator>Harish</dc:creator>
		<pubDate>Mon, 26 Oct 2009 02:57:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57018</guid>
		<description>FYI: in my test data, the select returns 2 values, but when i ran the query, i got only one row with @StrengthAppMenInstIDP1 as null, but it had a value.

Dont know where i am going wrong...

Harish</description>
		<content:encoded><![CDATA[<p>FYI: in my test data, the select returns 2 values, but when i ran the query, i got only one row with @StrengthAppMenInstIDP1 as null, but it had a value.</p>
<p>Dont know where i am going wrong&#8230;</p>
<p>Harish</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harish</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57017</link>
		<dc:creator>Harish</dc:creator>
		<pubDate>Mon, 26 Oct 2009 02:55:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-57017</guid>
		<description>Hi pinal,

i have a problem inserting multiple records into a table. My code looks like this:

	DECLARE @MyCursor CURSOR
	SET @MyCursor = CURSOR FAST_FORWARD
	FOR		
	SELECT strength_app_men_inst_id from TACF_WFTA_STRENGTH_APP_MEN_INST where wf_task_assignment_id = @WfTaskAssignmentIDP1 
	BEGIN TRAN t3
		BEGIN			
			OPEN @MyCursor
			WHILE @@FETCH_STATUS = 0
				BEGIN
				FETCH NEXT FROM @MyCursor
				INTO @StrengthAppMenInstIDP1
				END
				exec @ReturnCode = getid_sel @table = &#039;TACF_WFTA_STRENGTH_APP_MEN_INST&#039;, @id = @NewID2 OUTPUT, @mode = 2
				insert into TACF_WFTA_STRENGTH_APP_MEN_INST (id, wf_task_assignment_id, strength_app_men_inst_id) values (@NewID2, @WfTaskAssignmentIDP2, @StrengthAppMenInstIDP1)
			CLOSE @MyCursor
			DEALLOCATE @MyCursor	
		END
	IF @@error  0 
		ROLLBACK TRAN t3
	COMMIT TRAN t3


the select statement returns multiple values and i have to insert that into the same table. i know cursor is not a good way, but my select statement will always return a max of 10 values. Can you please check where i am going wrong, or a better way.

Can you please help me with this as soon as possible. I would really appreciate this.

Thanks,
Harish</description>
		<content:encoded><![CDATA[<p>Hi pinal,</p>
<p>i have a problem inserting multiple records into a table. My code looks like this:</p>
<p>	DECLARE @MyCursor CURSOR<br />
	SET @MyCursor = CURSOR FAST_FORWARD<br />
	FOR<br />
	SELECT strength_app_men_inst_id from TACF_WFTA_STRENGTH_APP_MEN_INST where wf_task_assignment_id = @WfTaskAssignmentIDP1<br />
	BEGIN TRAN t3<br />
		BEGIN<br />
			OPEN @MyCursor<br />
			WHILE @@FETCH_STATUS = 0<br />
				BEGIN<br />
				FETCH NEXT FROM @MyCursor<br />
				INTO @StrengthAppMenInstIDP1<br />
				END<br />
				exec @ReturnCode = getid_sel @table = &#8216;TACF_WFTA_STRENGTH_APP_MEN_INST&#8217;, @id = @NewID2 OUTPUT, @mode = 2<br />
				insert into TACF_WFTA_STRENGTH_APP_MEN_INST (id, wf_task_assignment_id, strength_app_men_inst_id) values (@NewID2, @WfTaskAssignmentIDP2, @StrengthAppMenInstIDP1)<br />
			CLOSE @MyCursor<br />
			DEALLOCATE @MyCursor<br />
		END<br />
	IF @@error  0<br />
		ROLLBACK TRAN t3<br />
	COMMIT TRAN t3</p>
<p>the select statement returns multiple values and i have to insert that into the same table. i know cursor is not a good way, but my select statement will always return a max of 10 values. Can you please check where i am going wrong, or a better way.</p>
<p>Can you please help me with this as soon as possible. I would really appreciate this.</p>
<p>Thanks,<br />
Harish</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gopu</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-56495</link>
		<dc:creator>Gopu</dc:creator>
		<pubDate>Wed, 07 Oct 2009 11:57:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-56495</guid>
		<description>Hi Dave,

How do we pronounce u&#039;r name.

thanks in advance. :)</description>
		<content:encoded><![CDATA[<p>Hi Dave,</p>
<p>How do we pronounce u&#8217;r name.</p>
<p>thanks in advance. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lugene</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-56302</link>
		<dc:creator>lugene</dc:creator>
		<pubDate>Thu, 01 Oct 2009 06:04:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-56302</guid>
		<description>My tables are SubjectTable and GradeTable.SubjectTable has datafields of Course, Subject, Units While GradeTable has Studname, Subjects, Grade, Remarks. I inserted datafields of subject from SujectTable to GradeTable. And it leaves the other rows blank. How can I Add data to a Null rows?Can somebody help me with this problem of mine....thanks</description>
		<content:encoded><![CDATA[<p>My tables are SubjectTable and GradeTable.SubjectTable has datafields of Course, Subject, Units While GradeTable has Studname, Subjects, Grade, Remarks. I inserted datafields of subject from SujectTable to GradeTable. And it leaves the other rows blank. How can I Add data to a Null rows?Can somebody help me with this problem of mine&#8230;.thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Darshan</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-56165</link>
		<dc:creator>Darshan</dc:creator>
		<pubDate>Fri, 25 Sep 2009 13:53:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-56165</guid>
		<description>Hi Mitch,
Basically we have to use select * into for temporary tables.
We can use it to create basic structure with Data.
But if you want to create table with all details then first you have to create script for it. 
GO Enterprise manager-&gt;right click on  object -&gt;Generate Script -&gt;Create -&gt;copy the script and use that script to create new object. 
after then use insert statment with select. 

I hope this will help you. 


Thanks 
Darshan Shah</description>
		<content:encoded><![CDATA[<p>Hi Mitch,<br />
Basically we have to use select * into for temporary tables.<br />
We can use it to create basic structure with Data.<br />
But if you want to create table with all details then first you have to create script for it.<br />
GO Enterprise manager-&gt;right click on  object -&gt;Generate Script -&gt;Create -&gt;copy the script and use that script to create new object.<br />
after then use insert statment with select. </p>
<p>I hope this will help you. </p>
<p>Thanks<br />
Darshan Shah</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Darshan</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-56164</link>
		<dc:creator>Darshan</dc:creator>
		<pubDate>Fri, 25 Sep 2009 13:49:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-56164</guid>
		<description>Hi Rushi,
You are going right way. You have to use transaction. 
while inserting records in child table first you have to find that that record is already exist or not ,if not then first store into one local variable and then add it into master table first and then add in child table. 

I hope u will get it . 

Thanks 
Darshan Shah</description>
		<content:encoded><![CDATA[<p>Hi Rushi,<br />
You are going right way. You have to use transaction.<br />
while inserting records in child table first you have to find that that record is already exist or not ,if not then first store into one local variable and then add it into master table first and then add in child table. </p>
<p>I hope u will get it . </p>
<p>Thanks<br />
Darshan Shah</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rushi</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-55887</link>
		<dc:creator>Rushi</dc:creator>
		<pubDate>Tue, 15 Sep 2009 11:59:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-55887</guid>
		<description>Hi,

how do i insert br_no?

i have created a table1 mst_brng( br_no)pk
i have created a table2 sec_mst_brng(br_no,br_mk)br_no is a FK
and i want to insert the br_no in table2(br_no, br_mk)
but i want check first if br_no allready in master table than no problem,
 but if it is not in master table than i want to insert data through child table so for this what should i do</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>how do i insert br_no?</p>
<p>i have created a table1 mst_brng( br_no)pk<br />
i have created a table2 sec_mst_brng(br_no,br_mk)br_no is a FK<br />
and i want to insert the br_no in table2(br_no, br_mk)<br />
but i want check first if br_no allready in master table than no problem,<br />
 but if it is not in master table than i want to insert data through child table so for this what should i do</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rushi</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-55882</link>
		<dc:creator>Rushi</dc:creator>
		<pubDate>Tue, 15 Sep 2009 11:25:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-55882</guid>
		<description>I tried by making TransactionOption to be Required.
i want to insert a data throug child table
for this i want to check if the data is  all ready in master table than no problem,
but if it is not in master table than i want ot insert data through child table.which is connect with the master table
so please tell me what should i do</description>
		<content:encoded><![CDATA[<p>I tried by making TransactionOption to be Required.<br />
i want to insert a data throug child table<br />
for this i want to check if the data is  all ready in master table than no problem,<br />
but if it is not in master table than i want ot insert data through child table.which is connect with the master table<br />
so please tell me what should i do</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ANJAN GHOSH</title>
		<link>http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-55664</link>
		<dc:creator>ANJAN GHOSH</dc:creator>
		<pubDate>Mon, 07 Sep 2009 11:19:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/#comment-55664</guid>
		<description>SEND ME A FUNCTION PROCEDURE</description>
		<content:encoded><![CDATA[<p>SEND ME A FUNCTION PROCEDURE</p>
]]></content:encoded>
	</item>
</channel>
</rss>
