Hello,
is there a way to copy a table from database A to database B?
I use sql server 2005 express and Management Studio.
Thanks
Albert
Plamen Ratchev - 08 Jul 2008 18:07 GMT
If you have the table structure already created in the target database, you
can use 3 part notation to reference the tables:
INSERT INTO DatabaseB..Table (<columns>)
SELECT <columns> FROM DatabaseA..Table;
Note this assumes default schema for the user. If you have specific schema
names you should reference it:
INSERT INTO DatabaseB.schema_name.Table (<columns>)
SELECT <columns> FROM DatabaseA.schema_name.Table;
You can use SELECT INTO if the target table does not exist, but that will
not copy any constraints or indexes. Best is to script the table and create
in advance, then insert the data.
HTH,
Plamen Ratchev
http://www.SQLStudio.com
Albert - 08 Jul 2008 20:40 GMT
Thanks
> If you have the table structure already created in the target database,
> you can use 3 part notation to reference the tables:
[quoted text clipped - 16 lines]
> Plamen Ratchev
> http://www.SQLStudio.com
Linchi Shea - 08 Jul 2008 18:12 GMT
You can use the Import/Export wizard from Management Studio. Right click on a
database -> Tasks -> Import Data ..., and follow the GUI.
Linchi
> Hello,
>
> is there a way to copy a table from database A to database B?
> I use sql server 2005 express and Management Studio.
> Thanks
> Albert
Albert - 08 Jul 2008 20:41 GMT
Thanks, but unfortunately, there is no import/export wizard in Management
Studio express ....
> You can use the Import/Export wizard from Management Studio. Right click
> on a
[quoted text clipped - 8 lines]
>> Thanks
>> Albert