Copy the tables and data on the remote server to the local database by using a script

Source: Internet
Author: User

EXECsp_addlinkedserver@server='Srv_lnk',@srvproduct="',@provider='SQLOLEDB',@datasrc='Helios01.us.psav.dom\helioslistener'EXECsp_addlinkedsrvlogin'Srv_lnk','false',NULL,'Shinetechpsav','CEJE5R+SP' UseworkforcemanagementBEGINTRY--BEGIN TRANSACTION    DROP TABLECommentsDROP TABLECustomer_excludeDROP TABLEDeptstatusDROP TABLEforecast_hourlyDROP TABLEforecast_revenueDROP TABLEforecast_salaryDROP TABLEForecast_schedule_changeDROP TABLEFreelanceDROP TABLE HistoryDROP TABLEInvgroupDROP TABLELastupdatetablesDROP TABLE [Login]    DROP TABLEnwf_all_employeesDROP TABLEnwf_closed_actualDROP TABLENwf_closed_forecastDROP TABLEnwf_holidaysDROP TABLEnwf_liveDROP TABLENwf_qb_percDROP TABLEnwf_sitesDROP TABLENwf_supervisor_nameDROP TABLEnwf_supervisor_regionDROP TABLENwf_supervisor_siteDROP TABLEOvertime_reportDROP TABLEPaypolicyDROP TABLEquickcommentDROP TABLE RegionDROP TABLESalaryDROP TABLEtransfer_positionsDROP TABLETransfersDROP TABLEUltipro_apiDROP TABLE [Union]    DROP TABLEunion_positionsGO; SELECT *  intoComments fromsrv_lnk.WorkForceManagement.dbo.CommentsSELECT *  intoCustomer_exclude fromSrv_lnk. WorkForceManagement.dbo.Customer_Exclude with(NOLOCK)SELECT *  intoDeptstatus fromSrv_lnk. WorkForceManagement.dbo.DeptStatus with(NOLOCK)SELECT *  intoForecast_hourly fromSrv_lnk. WorkForceManagement.dbo.Forecast_Hourly with(NOLOCK)SELECT *  intoForecast_revenue fromSrv_lnk. WorkForceManagement.dbo.Forecast_Revenue with(NOLOCK)SELECT *  intoForecast_salary fromSrv_lnk. WorkForceManagement.dbo.Forecast_Salary with(NOLOCK)SELECT *  intoForecast_schedule_change fromSrv_lnk. WorkForceManagement.dbo.Forecast_Schedule_Change with(NOLOCK)SELECT *  intoFreelance fromSrv_lnk. WorkForceManagement.dbo.Freelance with(NOLOCK)SELECT *  intoHistory fromSrv_lnk. WorkForceManagement.dbo.History with(NOLOCK)SELECT *  intoInvgroup fromSrv_lnk. WorkForceManagement.dbo.InvGroup with(NOLOCK)SELECT *  intoLastupdatetables fromSrv_lnk. WorkForceManagement.dbo.LastUpdateTables with(NOLOCK)SELECT *  into [Login]  fromSrv_lnk. Workforcemanagement.dbo.[Login]  with(NOLOCK)SELECT *  intoNwf_all_employees fromSrv_lnk. WorkForceManagement.dbo.NWF_All_Employees with(NOLOCK)SELECT *  intoNwf_closed_actual fromSrv_lnk. WorkForceManagement.dbo.NWF_Closed_ACTUAL with(NOLOCK)SELECT *  intoNwf_closed_forecast fromSrv_lnk. WorkForceManagement.dbo.NWF_Closed_FORECAST with(NOLOCK)SELECT *  intoNwf_holidays fromSrv_lnk. WorkForceManagement.dbo.NWF_Holidays with(NOLOCK)SELECT *  intoNwf_live fromSrv_lnk. WorkForceManagement.dbo.NWF_Live with(NOLOCK)SELECT *  intoNwf_qb_perc fromSrv_lnk. WorkForceManagement.dbo.NWF_QB_Perc with(NOLOCK)SELECT *  intoNwf_sites fromSrv_lnk. WorkForceManagement.dbo.NWF_Sites with(NOLOCK)SELECT *  intoNwf_supervisor_name fromSrv_lnk. WorkForceManagement.dbo.NWF_Supervisor_Name with(NOLOCK)SELECT *  intoNwf_supervisor_region fromSrv_lnk. WorkForceManagement.dbo.NWF_Supervisor_Region with(NOLOCK)SELECT *  intoNwf_supervisor_site fromSrv_lnk. WorkForceManagement.dbo.NWF_Supervisor_Site with(NOLOCK)SELECT *  intoOvertime_report fromSrv_lnk. WorkForceManagement.dbo.OverTime_Report with(NOLOCK)SELECT *  intoPaypolicy fromSrv_lnk. WorkForceManagement.dbo.PayPolicy with(NOLOCK)SELECT *  intoQuickcomment fromSrv_lnk. WorkForceManagement.dbo.QuickComment with(NOLOCK)SELECT *  intoRegion fromSrv_lnk. WorkForceManagement.dbo.Region with(NOLOCK)SELECT *  intoSalary fromSrv_lnk. WorkForceManagement.dbo.Salary with(NOLOCK)SELECT *  intoTransfer_positions fromSrv_lnk. WorkForceManagement.dbo.Transfer_Positions with(NOLOCK)SELECT *  intoTransfers fromSrv_lnk. WorkForceManagement.dbo.Transfers with(NOLOCK)SELECT *  intoUltipro_api fromSrv_lnk. WorkForceManagement.dbo.UltiPro_API with(NOLOCK)SELECT *  into [Union]  fromSrv_lnk. Workforcemanagement.dbo.[Union]  with(NOLOCK)SELECT *  intoUnion_positions fromSrv_lnk. WorkForceManagement.dbo.Union_Positions with(NOLOCK)--COMMIT TRANSACTIONENDTRYBEGINCATCH--ROLLBACK TRANSACTIONENDCatch

Copy the tables and data on the remote server to the local database by using a script

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.