September 20, 2011 at 6:47 am
Hi ..
I have two database name AA and AAA..
AA database contains the data ...
and AAA its a empty database containing same tables
in both the database..
now i want to insert the values from
AA to AAA but... first i need to insert the parent
table and then child table ...
I want to create a new table containing
the parent table first and then child table ...
so that i can insert the values easily ..
or is there any option to do inserting in empty database ...
can anybody help to do this...
September 20, 2011 at 6:52 am
vinayak.v (9/20/2011)
Hi ..I have two database name AA and AAA..
AA database contains the data ...
and AAA its a empty database containing same tables
in both the database..
now i want to insert the values from
AA to AAA but... first i need to insert the parent
table and then child table ...
I want to create a new table containing
the parent table first and then child table ...
so that i can insert the values easily ..
or is there any option to do inserting in empty database ...
can anybody help to do this...
If you are looking to move ALL tables from AA to AAA... force restore a current backup of AA database on top of AAA database 🙂
If you are looking to move SOME tables from AA to AAA... disable all FK constraints, move the data, re-enable FK constraints. Since data is kosher on AA no reason to believe it will get screwed up when moved to AAA - on top of it, inserts will work faster with no referential integrity in place at refresh time.
_____________________________________
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.September 20, 2011 at 6:55 am
Thanks for the reply ..
Actually the scenario is i'm using merge statement for the
sync process where i have to give table name of parent first
and then child ..
that's y i need the parent table list and also child...
September 20, 2011 at 6:55 am
use T-SQL insert into
or
SSIS
from one db to the other..
September 20, 2011 at 6:57 am
But ... how to enable and disable the foreign key in script ...
September 20, 2011 at 6:58 am
you can use sp_fkeys [ParentTable] to generate a list of child table references;
from there you can use that list to script your merge statements...does that help?
Lowell
September 20, 2011 at 7:06 am
vinayak.v (9/20/2011)
But ... how to enable and disable the foreign key in script ...
Dont bother with this, they are there for a reason just insert the data the in correct order to maintain RI,
September 20, 2011 at 7:10 am
Thanks Steveb ...
Is there any process to sync two database
except replication, third party tool ... ?
September 20, 2011 at 7:11 am
vinayak.v (9/20/2011)
Thanks Steveb ...Is there any process to sync two database
except replication, third party tool ... ?
I always use SQL data compare from Redgate , excellent tool and well worth the ££
September 20, 2011 at 7:14 am
If the database is small enough, you could script out all of the data -- right click on DB in SSMS and chooses Tasks, Generate Scripts. Then run that script against the second db (AAA) to insert it there. Your referential integrity will still be fine.
Rob
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply