Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Saving tables and restoring them
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Desktop
Divers
Thread ID:
01624235
Message ID:
01624241
Vues:
27
>>>>>>I would like to be able to copy a few tables (some in a relationship) from time to time and then restore the state from the copies.
>>>>>>To save the tables
insert to _newtable_ from _oldtable_
works nicely. But to recopy into the orignal tables seems to be tricky, due to identity, foreign keys etc.
>>>>>>
>>>>>>Is there a simple way to do this? (copy with production :) )
>>>>>
>>>>>You will have to copy tables in order (Parent table first, then related tables) and you would need to SET IDENTITY_INSERT ON for these tables.$
>>>>
>>>>... and list the columns in the restoring process right?
>>>
>>>Yes, of course. You should always list all columns in the INSERT command, don't take shortcuts.
>>Sure but this is just a utility i need in development. And I wanted to make something generic for multiple tables.
>>I was wondering if it would not be better to strip off the keys and the constraints, copy back (via insert into from) and then restore the keys and the relations (in tsql).
>
>This is another approach you can take. It may be easier and quicker.

Many thanks for your support :)

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform