Sql Server跨服务器操作数据

var serversSql = "select count(*) count from sys.servers WHERE name='ITSV'";
var result = BaseSqlHelper.ExecuteScalar(serversSql);
if (result.ToString() == "0")
{
    var addServersSql = "exec sp_addlinkedserver   'ITSV ', ' ', 'SQLOLEDB ', '远程服务器名或ip地址' ";
    BaseSqlHelper.ExecuteNonQuery(addServersSql);
}
var sql = @"INSERT ITSV.AD.dbo.DEPT SELECT ID DeptID,ParentID,Name DeptName,SortIndex SequenceID,OperateStatus,GETDATE() LastUpdateTime FROM dbo.S_A_Org WHERE ISNULL(OperateStatus,0)=0";
BaseSqlHelper.ExecuteNonQuery(sql);

https://www.cnblogs.com/lihuiqi/p/11067894.html

posted @ 2019-10-28 18:43  yomi丶  阅读(181)  评论(0编辑  收藏  举报