通过脚本把远程服务器上的表和数据拷贝到本地数据库

EXEC sp_addlinkedserver @server=‘srv_lnk‘, @srvproduct=‘‘, @provider=‘SQLOLEDB‘, @datasrc=‘HELIOS01.us.psav.dom\HELIOSLISTENER‘
EXEC sp_addlinkedsrvlogin ‘srv_lnk‘, ‘false‘, NULL, ‘ShinetechPSAV‘, ‘CeJe5r+sp‘

USE WorkForceManagement
BEGIN TRY
    --BEGIN TRANSACTION

    DROP TABLE Comments
    DROP TABLE Customer_Exclude
    DROP TABLE DeptStatus
    DROP TABLE Forecast_Hourly
    DROP TABLE Forecast_Revenue
    DROP TABLE Forecast_Salary
    DROP TABLE Forecast_Schedule_Change
    DROP TABLE Freelance
    DROP TABLE History
    DROP TABLE InvGroup
    DROP TABLE LastUpdateTables
    DROP TABLE [Login]
    DROP TABLE NWF_All_Employees
    DROP TABLE NWF_Closed_ACTUAL
    DROP TABLE NWF_Closed_FORECAST
    DROP TABLE NWF_Holidays
    DROP TABLE NWF_Live
    DROP TABLE NWF_QB_Perc
    DROP TABLE NWF_Sites
    DROP TABLE NWF_Supervisor_Name
    DROP TABLE NWF_Supervisor_Region
    DROP TABLE NWF_Supervisor_Site
    DROP TABLE OverTime_Report
    DROP TABLE PayPolicy
    DROP TABLE QuickComment
    DROP TABLE Region
    DROP TABLE Salary
    DROP TABLE Transfer_Positions
    DROP TABLE Transfers
    DROP TABLE UltiPro_API
    DROP TABLE [Union]
    DROP TABLE Union_Positions

    GO;

    SELECT * INTO Comments FROM srv_lnk.WorkForceManagement.dbo.Comments
    SELECT * INTO Customer_Exclude FROM srv_lnk.WorkForceManagement.dbo.Customer_Exclude WITH(NOLOCK)
    SELECT * INTO DeptStatus FROM srv_lnk.WorkForceManagement.dbo.DeptStatus WITH(NOLOCK)
    SELECT * INTO Forecast_Hourly FROM srv_lnk.WorkForceManagement.dbo.Forecast_Hourly WITH(NOLOCK)
    SELECT * INTO Forecast_Revenue FROM srv_lnk.WorkForceManagement.dbo.Forecast_Revenue WITH(NOLOCK)
    SELECT * INTO Forecast_Salary FROM srv_lnk.WorkForceManagement.dbo.Forecast_Salary WITH(NOLOCK)
    SELECT * INTO Forecast_Schedule_Change FROM srv_lnk.WorkForceManagement.dbo.Forecast_Schedule_Change WITH(NOLOCK)
    SELECT * INTO Freelance FROM srv_lnk.WorkForceManagement.dbo.Freelance WITH(NOLOCK)
    SELECT * INTO History FROM srv_lnk.WorkForceManagement.dbo.History WITH(NOLOCK)
    SELECT * INTO InvGroup FROM srv_lnk.WorkForceManagement.dbo.InvGroup WITH(NOLOCK)
    SELECT * INTO LastUpdateTables FROM srv_lnk.WorkForceManagement.dbo.LastUpdateTables WITH(NOLOCK)
    SELECT * INTO [Login] FROM srv_lnk.WorkForceManagement.dbo.[Login] WITH(NOLOCK)
    SELECT * INTO NWF_All_Employees FROM srv_lnk.WorkForceManagement.dbo.NWF_All_Employees WITH(NOLOCK)
    SELECT * INTO NWF_Closed_ACTUAL FROM srv_lnk.WorkForceManagement.dbo.NWF_Closed_ACTUAL WITH(NOLOCK)
    SELECT * INTO NWF_Closed_FORECAST FROM srv_lnk.WorkForceManagement.dbo.NWF_Closed_FORECAST WITH(NOLOCK)
    SELECT * INTO NWF_Holidays FROM srv_lnk.WorkForceManagement.dbo.NWF_Holidays WITH(NOLOCK)
    SELECT * INTO NWF_Live FROM srv_lnk.WorkForceManagement.dbo.NWF_Live WITH(NOLOCK)
    SELECT * INTO NWF_QB_Perc FROM srv_lnk.WorkForceManagement.dbo.NWF_QB_Perc WITH(NOLOCK)
    SELECT * INTO NWF_Sites FROM srv_lnk.WorkForceManagement.dbo.NWF_Sites WITH(NOLOCK)
    SELECT * INTO NWF_Supervisor_Name FROM srv_lnk.WorkForceManagement.dbo.NWF_Supervisor_Name WITH(NOLOCK)
    SELECT * INTO NWF_Supervisor_Region FROM srv_lnk.WorkForceManagement.dbo.NWF_Supervisor_Region WITH(NOLOCK)
    SELECT * INTO NWF_Supervisor_Site FROM srv_lnk.WorkForceManagement.dbo.NWF_Supervisor_Site WITH(NOLOCK)
    SELECT * INTO OverTime_Report FROM srv_lnk.WorkForceManagement.dbo.OverTime_Report WITH(NOLOCK)
    SELECT * INTO PayPolicy FROM srv_lnk.WorkForceManagement.dbo.PayPolicy WITH(NOLOCK)
    SELECT * INTO QuickComment FROM srv_lnk.WorkForceManagement.dbo.QuickComment WITH(NOLOCK)
    SELECT * INTO Region FROM srv_lnk.WorkForceManagement.dbo.Region WITH(NOLOCK)
    SELECT * INTO Salary FROM srv_lnk.WorkForceManagement.dbo.Salary WITH(NOLOCK)
    SELECT * INTO Transfer_Positions FROM srv_lnk.WorkForceManagement.dbo.Transfer_Positions WITH(NOLOCK)
    SELECT * INTO Transfers FROM srv_lnk.WorkForceManagement.dbo.Transfers WITH(NOLOCK)
    SELECT * INTO UltiPro_API FROM srv_lnk.WorkForceManagement.dbo.UltiPro_API WITH(NOLOCK)
    SELECT * INTO [Union] FROM srv_lnk.WorkForceManagement.dbo.[Union] WITH(NOLOCK)
    SELECT * INTO Union_Positions FROM srv_lnk.WorkForceManagement.dbo.Union_Positions WITH(NOLOCK)

    --COMMIT TRANSACTION
END TRY

BEGIN CATCH
    --ROLLBACK TRANSACTION
END CATCH
时间: 2024-12-08 23:43:50

通过脚本把远程服务器上的表和数据拷贝到本地数据库的相关文章

pexpect练习实例--批量执行远程服务器上的指定脚本

经过几天的学习,pexpect模块对于linux下运维脚本编写属实有用,下面写个脚本检验下学习效果. #!/usr/bin/env python #coding=utf-8 #远程执行服务器上的脚本 import sys, time, os, multiprocessing try: import pexpect except ImportError: print """ You must install pexpect module """ s

运维小东西:每天备份sql到远程服务器上

首先两台服务器可以无密码登录(这个方式比较简单,当然安全系数会降低) #ssh-keygen -t rsa #生成密钥发送给远程服务器上 #ssh-copy-id ~/root/id_rsa.pub [email protected] 这样ssh的时候就不用输入密码了.对于crontab这种定时自动运行的任务来说还是比较方便的. 现在就是写shell备份sql到远程服务器的脚本: #!/bin/sh DB_NAME1="" DB_USER="" DB_PASS=&q

在Mac机器上给ITerm2配置lrzsz,便捷的传输文件到远程服务器上

可直接参考文档:http://danqingdani.blog.163.com/blog/static/18609419520141201215750 需要使用到的github脚本:https://github.com/mmastrac/iterm2-zmodem 或简明步骤如下: 1.安装Iterm2, homebrew 2.安装lrzsz: $brew install lrzsz 3.下载github上的脚本,然后copy到/usr/local/bin中 4.在ITerm2中对应的profi

解决git pull 命令失效,不能从远程服务器上拉取代码问题

用时候在用Git pull命令的时候不管用,拉取不下来远程分支上的代码,是因为本地分支和远程分支没有建立关联. 处理这种问题很简单就按照提示执行命令即可:git branch --set-upstream-to=origin/fixbug-2.9.8 fixbug-2.9.8 如果想保证这种情况不出现就在建立新分支推送到远程分支上的时候加上-u参数即可 git push -u origin feature- 解决git pull 命令失效,不能从远程服务器上拉取代码问题

scp 从远程服务器上一下载文件

scp -P202 xx3.x6.xx.xx:/usr/local/zookeeper-3.4.6.zip /tmp #指定远程服务器的端口和远程服务器的目标文件 ,最后指定要下载到本的地目录 也可以从远程服务器上把整个目录下载下来: scp -P3332 -r xx2.x2.1xxx.x4:/apps/tengine ./ #把远程服务器上的tengine目录下载到本地当前目录里 注意:如果远程主机的目标目录有同名的文件会被强制覆盖!!!

在远程服务器上完成本地设备的程序烧写和调试(基于vivado ,SDK软件)

在使用vivado和SDK进行设计开发的时候,通常需要登录到远程服务器上进行,但是会遇到一个问题就是,所使用的开发板通常是连接在自己的电脑上(local-PC),那要怎么才能让运行在服务器上的设计软件检测到连接在本地的设备呢?Vivado开发套件提供了一个解决方法,就是使用Hardware Server,具体实现步骤如下: 1. 在local-PC上找到Vivado或SDK的安装目录,并在该目录下找到hw_server程序,具体路径为: <Vivado_install_root>\bin或者&

模拟php curl向远程服务器上传文件

test.php: <?php header('content-type:text/html;charset=utf8'); $ch = curl_init(); //加@符号curl就会把它当成是文件上传处理 $data = array('img'=>'@'. dirname(__FILE__).'/img/1.jpg'); curl_setopt($ch,CURLOPT_URL,"http://localhost:8088/curl/get_img.php"); cur

使用UIWebView加载本地或远程服务器上的网页

大家都知道,使用UIWebView加载本地或远程服务器上的网页,sdk提供了三个加载接口: - (void)loadRequest:(NSURLRequest *)request; - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL; - (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)

如何把云端服务器上的file04.c文件传输到本地pc机windows系统上去呢?

一般服务器会放在机房,很多时候我们一般是通过一某个终端软件进行远程连接到服务器,然后再去工作. 那么我们如何把云端服务器上的file04.c文件传输到本地pc机windows系统上去呢? 1.在SecureCRT上的链接对话框右键打开 之后选择 连接SFTP会话2.在sftp里面要分别要进入远程服务器的路径和本地的路径,如下: 先用命令pwd 查看远程的linux的目录 cd /home/chen/001/01/文件操作day01/   进入远程的linux下存放文件的目录 lpwd 查看本地的