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

上一篇:c#.net+SQL2005 实现简单搜索


下一篇:T-SQL RIGHT JOIN