One, copy the database one table to another database (same server) SELECT * into table 1 from table 2--Copy table 2 If you only copy the structure without copying the content or just a column, just add the Where condition. Example:
(Copy the Syslog table from database aimmanagedb to database imcdb)
Second, copy a table from one database to another (cross-server)
Example: select * into [SMSDB]. [dbo]. [SysLog] From OPENROWSET (' SQLOLEDB ', ' target server '; ' Account '; ' Password ', [Smsdb]. [dbo]. [SysLog])
(Copy the Syslog table from the database target server to the local database smsdb)
eg: if the following error occurs:
sql Server blocked access to the Queries ' STATEMENT ' of the component ' Ad Hoc distributed Openrowset/opendatasource '. Because this component has been shut down as part of this server's security configuration.
Workaround:
1, system administrator can enable ' Ad Hoc distributed Queries '
in local SQL by using sp_configure exec sp_configure ' show advanced options ', 1 reconfigure exec sp_configure ' Ad Hoc distributed Queries ', 1 reconfigure
2. After the use is complete, close the ad Hoc distributed Queries:
exec sp_configure ' Ad Hoc distributed Queries ', 0 reconfigure exec sp_configure ' show advanced options ', 0 reconfigure
other local import methods select * FROM table1 to table2 table2 must not exist insert into table2 select * FROM table1 table2 must exist
SQL Server replicates a table from one database to another (cross-server)