SQL Server replicates a table from one database to another (cross-server)

Source: Internet
Author: User
Tags one table syslog

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.