Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Create Inserts Statements

Author  Topic 

jai2808
Starting Member

27 Posts

Posted - 2012-04-05 : 03:29:01
Hi,
This is regarding creation of insert statements from SQL Server 2008, we can use generate scripts and script data only.
My question is i have somewhere around 30 tables and some of the tables there is a fk refernce. When i generate the insert steatement script will SQL place the tables accordingly as per the FK <>PK relationship. That is it creates insert statements for MAster table first and then the child tables.

Is SQL automatically does this.

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-04-05 : 11:18:10
I don't think that it will but I could be wrong. What results are you seeing when you tried doing this?

=================================================
There is a foolish corner in the brain of the wisest man. -Aristotle, philosopher (384-322 BCE)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-05 : 15:12:59
nope. it wont

you would need to churn out logic like below to get correct order of tables

http://visakhm.blogspot.com/2011/11/recursive-delete-from-parent-child.html

then use it generate inserts

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -