Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Duplicate/copy tables from one DB to another
Message
 
 
À
20/09/2017 17:54:25
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:
01654475
Vues:
47
>>>>>>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
>>>>>
>>>>
>>>>First, thank you. And even PK fields will have the same values?
>>>
>>>Yes. With this approach, initially there isn't even a primary key set. You can use alter commands and create index ... It might need more scripts depending on what exactly you want to achieve.
>>
>>Thank you. I will try this approach. Creating indexes I can do "manually" as long as all records are replicated in the second DB.
>
>Yes they would be. This is like doing "copy to" in VFP.

Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform