November 21, 2007 at 2:11 am
COPY TABLE FROM ONE DATABASE TO ANOTHER USING SQL SERVER 2000
AND IT IS IN SCRIPT.
November 21, 2007 at 2:27 am
If you want to copy table including data you can try the below querry
select * into
otherwise if you want to copy ony the table structure try below querry
select top 0 * into
November 21, 2007 at 2:29 am
If you want to copy table including data you can try the below querry
select * into otherdbname..tblname from currentdbname..tblname
otherwise if you want to copy ony the table structure try below querry
select top 0 * into otherdbname..tblname from currentdbname..tblname
November 21, 2007 at 6:46 am
You can use DTS to copy the table into other database
November 21, 2007 at 7:58 pm
dhara is right you can use DTS for transferring tables but if you want to use a script there are some that can provide you what you want just like the following:
1. If you want to create a copy of the table and data in the same database you can use this script. (Attached below)
2. If you want to copy the table schema in another database and you have an access to the enterprise manager you can do this :
2.a Go to the table name
2.b Right click the table nae
2.c Paste in the Query Analyzer
2.d run the pasted table schema
2.1 If you do not have access in the EM and only want to copy the table schem you can also use the script below (just read instructions for limitations)
3. If you already copied the table in other database (the table do not have any data inside) just run this script (supply valid information)
INSERT INTO table_name_copy SELECT * FROM db_name.db_owner.table
"-=Still Learning=-"
Lester Policarpio
November 21, 2007 at 8:30 pm
Hi,
The best and the fast solution is using DTS.
DTS tutorial
The best site for DTS and SSIS is http://www.sqldts.com/
http://www.verio.com/support/documents/view_article.cfm?doc_id=3846
Regards,
Ahmed
November 22, 2007 at 8:53 pm
thank for the code.. ^_^
I finished my module because of this.
:P:P :):)
November 23, 2007 at 7:31 am
dgvsbabu (11/21/2007)
If you want to copy table including data you can try the below querryselect * into otherdbname..tblname from currentdbname..tblname
otherwise if you want to copy ony the table structure try below querry
select top 0 * into otherdbname..tblname from currentdbname..tblname
This will lose all the indexes etc
James Horsley
Workflow Consulting Limited
November 25, 2007 at 11:39 pm
Thanks for the correction James like i said in my first post this scripts has limitations hmm just revised it to add the recreation of index can someone check this to see what other adjustments must be made? Again i just want to emphasized that this script is made out of curiosity and like previous posters here DTS can also do the trick just made a script like this to see if it is possible thanks!!
"-=Still Learning=-"
Lester Policarpio
November 26, 2007 at 4:46 am
I would prefer DTS rather than SqlCode.
Because DTS will copyy the entire structure as it is in the another database. But when you use code it will not carry indexes along with it. Just the plain copy of table would be moved to the destination database.
karthik
November 26, 2007 at 4:57 am
This actually sounds like it might be a target for replication rather than DTS
James Horsley
Workflow Consulting Limited
April 30, 2008 at 11:00 am
Lester,
Thanks this was helpful to me on a related matter...
Ron
Lester Policarpio (11/21/2007)
dhara is right you can use DTS for transferring tables but if you want to use a script there are some that can provide you what you want just like the following:1. If you want to create a copy of the table and data in the same database you can use this script. (Attached below)
2. If you want to copy the table schema in another database and you have an access to the enterprise manager you can do this :
2.a Go to the table name
2.b Right click the table nae
2.c Paste in the Query Analyzer
2.d run the pasted table schema
2.1 If you do not have access in the EM and only want to copy the table schem you can also use the script below (just read instructions for limitations)
3. If you already copied the table in other database (the table do not have any data inside) just run this script (supply valid information)
INSERT INTO table_name_copy SELECT * FROM db_name.db_owner.table
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply