Showing posts with label keeping. Show all posts
Showing posts with label keeping. Show all posts

Sunday, February 19, 2012

copy tables of a database to another

Hi,

I have 2 databases and each of them has different tables. I want to copy all of tables of database A to database B while keeping the existing tables of database B.

What is the best solution?

Thanksuse DTS (Data Transformation Services), it's in sql server.|||Thanks for help.

DTS is easy to use. I selected the 3rd radiobutton "copy objects and data" to copy tables from DB A to B.

If I have the same table name in 5 DB - A, B, C, D, E,
A is the central DB,
the data of those tables in B to E will be copied to A's table daily,
can the index be auto-generated and appended to A's table?

e.g. The index in DB A's table are
1
2
3
4
5

I add 4 rows of DB B's table data to A.

Will the index in DB A's table like:
1
2
3
4
5
6
7
8
9

where 6-9 come from DB B.

I saw that there is an overwrite or append data options in DTS. Do I just choose 'Append' and it will do that?

If I set the schedule, can it be done daily?

Thanks for advice.|||it really depends on how tables B, C, D, E are set up, if you are meaning index=primary key, then you'll probably need to run your own insert statements to insert into table A, so they will get new primary keys, unless you want to run the risk of having duplicate primary keys inserted, which then, they really are usless and aren't primary keys. Then you have to wonder about other tables that are linked to these tables based on that primary key, do you now have to update them as well? yuck. Don't know your data requirments here, but having 5 tables all hold the same thing is usually not a good idea.

DTS can be scheduled easily, the easiest way I know how is to right-click on the package in the DTS view in enterprise manager, and select schedule package.

Copy tables from one DB to another

Hi,
I have 2 databases and each of them has different tables. I want to copy all of tables of database A to database B while keeping the existing tables of database B.
What is the best solution?
Thanks
Use Data Import/Export Wizard. Its available under All Tasks when you right
click on the DB.
A problem with this though is that the newly created tables will have dbo as
the owner. If its a critical issue, a workaround is to save the script of
this script as vbs file and edit it manually.
Amol.
"Tom" <kerocow@.yahoo.com> wrote in message
news:28156BCB-6D94-4D1A-90C0-4B28C74CC92D@.microsoft.com...
> Hi,
> I have 2 databases and each of them has different tables. I want to copy
all of tables of database A to database B while keeping the existing tables
of database B.
> What is the best solution?
> Thanks
>
|||On Thu, 22 Apr 2004 06:41:02 -0700, Tom <kerocow@.yahoo.com> wrote:

>Hi,
>I have 2 databases and each of them has different tables. I want to copy all of tables of database A to database B while keeping the existing tables of database B.
>What is the best solution?
>Thanks
>
DTS (Click on Database A choose All Tasks Export), be aware that
indexes don't get copied (by design) if you choose the first choice
"copy Tables and Views", choose third option "copy objects and data"
to copy indexes as well.
Chris
|||Make sure you double check the default options. By Default it will select all data and also will copy all users.
Jeff
MCDBA, MCSE+I
|||On Thu, 22 Apr 2004 09:56:14 -0400, "Amol" <apk@.cbord.com> wrote:

>A problem with this though is that the newly created tables will have dbo as
>the owner.
-- How about running a script such as this to create a
-- script to change the table owner
-- Set Query results in text first
select 'sp_changeobjectowner [dbo.' + name + '],NEW_OWNER'
+ char(13) +'go'
from sysobjects where (uid in (1,3) and type='U')
-- regards
-- Chris
|||Thanks for help.
DTS is easy to use. I selected the 3rd radiobutton "copy objects and data" to copy tables from DB A to B.
If I have the same table name in 5 DB - A, B, C, D, E,
A is the central DB,
the data of those tables in B to E will be copied to A's table daily,
can the index be auto-generated and appended to A's table?
e.g. The index in DB A's table are
1
2
3
4
5
I add 4 rows of DB B's table data to A.
Will the index in DB A's table like:
1
2
3
4
5
6
7
8
9
where 6-9 come from DB B.
I saw that there is an overwrite or append data options in DTS. Do I just choose 'Append' and it will do that?
If I set the schedule, can it be done daily?
Thanks for advice.

Copy tables from one DB to another

Hi,
I have 2 databases and each of them has different tables. I want to copy all
of tables of database A to database B while keeping the existing tables of
database B.
What is the best solution?
ThanksUse Data Import/Export Wizard. Its available under All Tasks when you right
click on the DB.
A problem with this though is that the newly created tables will have dbo as
the owner. If its a critical issue, a workaround is to save the script of
this script as vbs file and edit it manually.
Amol.
"Tom" <kerocow@.yahoo.com> wrote in message
news:28156BCB-6D94-4D1A-90C0-4B28C74CC92D@.microsoft.com...
> Hi,
> I have 2 databases and each of them has different tables. I want to copy
all of tables of database A to database B while keeping the existing tables
of database B.
> What is the best solution?
> Thanks
>|||On Thu, 22 Apr 2004 06:41:02 -0700, Tom <kerocow@.yahoo.com> wrote:

>Hi,
>I have 2 databases and each of them has different tables. I want to copy al
l of tables of database A to database B while keeping the existing tables of
database B.
>What is the best solution?
>Thanks
>
DTS (Click on Database A choose All Tasks Export), be aware that
indexes don't get copied (by design) if you choose the first choice
"copy Tables and Views", choose third option "copy objects and data"
to copy indexes as well.
Chris|||Make sure you double check the default options. By Default it will select a
ll data and also will copy all users.
Jeff
MCDBA, MCSE+I|||On Thu, 22 Apr 2004 09:56:14 -0400, "Amol" <apk@.cbord.com> wrote:

>A problem with this though is that the newly created tables will have dbo a
s
>the owner.
-- How about running a script such as this to create a
-- script to change the table owner
--
-- Set Query results in text first
select 'sp_changeobjectowner [dbo.' + name + '],NEW_OWNER'
+ char(13) +'go'
from sysobjects where (uid in (1,3) and type='U')
-- regards
-- Chris|||Thanks for help.
DTS is easy to use. I selected the 3rd radiobutton "copy objects and data" t
o copy tables from DB A to B.
If I have the same table name in 5 DB - A, B, C, D, E,
A is the central DB,
the data of those tables in B to E will be copied to A's table daily,
can the index be auto-generated and appended to A's table?
e.g. The index in DB A's table are
1
2
3
4
5
I add 4 rows of DB B's table data to A.
Will the index in DB A's table like:
1
2
3
4
5
6
7
8
9
where 6-9 come from DB B.
I saw that there is an overwrite or append data options in DTS. Do I just ch
oose 'Append' and it will do that?
If I set the schedule, can it be done daily?
Thanks for advice.

Friday, February 17, 2012

Copy Table

How can I copy the table structure only (no data) keeping foreing key, indexes ...etc. I used DTS and it copied the table but not the relationship to other tables of index information
Thanks
Use Enterprise Manager to script the table. Just right click on the table
and select 'Generate SQL script', from the 'All tasks...' menu. Choose
appropriate options.
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
"Niles" <Niles@.discussions.microsoft.com> wrote in message
news:0130896A-7E01-409A-B111-3788CFD58522@.microsoft.com...
> How can I copy the table structure only (no data) keeping foreing key,
indexes ...etc. I used DTS and it copied the table but not the relationship
to other tables of index information
> Thanks

Copy Table

How can I copy the table structure only (no data) keeping foreing key, indexes ...etc. I used DTS and it copied the table but not the relationship to other tables of index information
ThanksUse Enterprise Manager to script the table. Just right click on the table
and select 'Generate SQL script', from the 'All tasks...' menu. Choose
appropriate options.
--
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
"Niles" <Niles@.discussions.microsoft.com> wrote in message
news:0130896A-7E01-409A-B111-3788CFD58522@.microsoft.com...
> How can I copy the table structure only (no data) keeping foreing key,
indexes ...etc. I used DTS and it copied the table but not the relationship
to other tables of index information
> Thanks

Copy Table

How can I copy the table structure only (no data) keeping foreing key, index
es ...etc. I used DTS and it copied the table but not the relationship to o
ther tables of index information
ThanksUse Enterprise Manager to script the table. Just right click on the table
and select 'Generate SQL script', from the 'All tasks...' menu. Choose
appropriate options.
--
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
"Niles" <Niles@.discussions.microsoft.com> wrote in message
news:0130896A-7E01-409A-B111-3788CFD58522@.microsoft.com...
> How can I copy the table structure only (no data) keeping foreing key,
indexes ...etc. I used DTS and it copied the table but not the relationship
to other tables of index information
> Thanks