refreshing table with fresh data | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

refreshing table with fresh data

I’m having problem with refreshing a table with live data from another table on a live server. the table has foreign key references
Without knowing what exactly your problems are I’d hazard a guess that you are unable to import some data because of foreign key contraints on tables. If you’re gonna import some data into a table that has such contraints you need a) turn off the constraints or b) make sure all the foreign keys exist in the other tables by refreshing those tables with data from the same server. I’d go for b) because you could end up in a mess with a) Cheers
Shaun World Domination Through Superior Software
the foreign keys exist in the development table but all i want to do is repopulate the development table with fresh data from same table in live.
Just recreate the foreign keys after exporting data from live db to development db using ALTER TABLE… refer to BOL for more information. _________
Satya SKJ

what you are saying is i should delete the relationships in E.M, export the table from live and then recreate the table using alter table.
How many tables are involved with this relationship? _________
Satya SKJ

error at destination for tow number 83979. errors encountered so far in this task:1. the statement has been terminated.
violation of primary key constraint ‘pk__t_xxxxxx’. cannot insert duplicate key in object ‘t_xxxxxx. I get the above error message after disabling the constraints and then trying to dts the table from source to destination.
Have you disabled referential integrity on development Db–table? _________
Satya SKJ

1 table
Then just disable on target database and try again. _________
Satya SKJ

You seem to having problems with both FK’s and PK’s while importing the data. Disable all Referential integrity (declarative or otherwise) and any Unique constraints you have in the table you are trying to refresh. By the way how are you refreshing the data ? DTS, BCP, BULK INSERT, INSERT…SELECT ? This might be helpful.
dts
Then just follow as referred. _________
Satya SKJ

what i’ve actually done is create a temp table, scripted out the development table, delete the relationships in E.M, dropped the table and then DTSed from live table and it seems to be fine. thanks all
]]>