Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Duplicate/copy tables from one DB to another
Message
De
20/09/2017 21:43:01
 
 
À
20/09/2017 17:43:03
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Maintenance bases de données
Divers
Thread ID:
01654465
Message ID:
01654476
Vues:
49
>>Hi,
>>
>>Say I have two tables in a SQL Server database, Parent and Child.
>>I want to copy/duplicate these two tables in another database keeping all records with their PK values the same. So that the second copy of the tables (in a new DB) is exactly the same as in the first.
>>How do you do it?
>
>Connection having access to both databases you simply use select into:
>
>
>select * into targetDb..targetTable from sourceDb..sourceTable
>
That will work the first time, but if the target table exists, it will crash.
Offhand, don't know the the SQL syntax to test and delete if present, but that will make this OK.
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform