菜鸟提问! trigger可不可以跨服务器访问操作啊 急!!!!!!

Nicholasqpl 2007-03-09 07:49:56
类似:
if exists(select WarehouseCode from [43.82.54.90].[slim].[dbo].[tblWarehouse] where WarehouseCode =@WarehouseCode AND StorerKey=@StorerKey)
begin
select distinct @EntityCode=EntityCode, @DivisionCode=DivisionCode FROM [43.82.54.90].[slim].[dbo].[tblWarehouse] where WarehouseCode =@WarehouseCode AND StorerKey=@StorerKey
end
else if exists(select WarehouseCode from [43.82.54.90].[slim].[dbo].[tblWarehouse] where WarehouseCode =@WarehouseCode )
begin
select top 1 @EntityCode=EntityCode, @DivisionCode=DivisionCode FROM [43.82.54.90].[slim].[dbo].[tblWarehouse] where WarehouseCode =@WarehouseCode
insert into [43.82.54.90].[slim].[dbo].[tblWarehouse] (WarehouseCode,DivisionCode,EntityCode,StorerKey,Priority,Address,ModifiedBy,ModifiedOn) values(@WarehouseCode,@DivisionCode,@EntityCode,@StorerKey,1,'Default Adress','Trigger',getdate())
end
...全文
311 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
弘毅致远 2007-03-12
  • 打赏
  • 举报
回复
只要已经建立了连接应该是可以的....
dali88888 2007-03-11
  • 打赏
  • 举报
回复
学习,up
leo_lesley 2007-03-10
  • 打赏
  • 举报
回复

--建立连接服务器
EXEC sp_addlinkedserver
--要创建的链接服务器名称
--这里就用数据源作名称
'218.204.111.111,3342',
'SQL Server'
GO


--创建链接服务器上远程登录之间的映射
EXEC sp_addlinkedsrvlogin
'218.204.111.111,3342',
'false',
NULL,
--远程服务器的登陆用户名
'zhangzhe',
--远程服务器的登陆密码
'fish2231'
go


--查询数据
select * from [218.204.253.131,3342].pubs.dbo.jobs
go
leo_lesley 2007-03-10
  • 打赏
  • 举报
回复
两个服务器先建立连接,然后就可以正常使用了。
simonhehe 2007-03-09
  • 打赏
  • 举报
回复
可以
-------------------------------------------
----这里是一个两库触发的例子
----你的连接已经建立,只需要修改from..即可
-------------------------------------------
create database B
go
use B
go
create table man(a int, b int, c int, d int)
go

--
create database A
go
use A
go
create table man(a int, b int, c int)

create trigger tr_man_delete on man
for delete
as
delete tmpB
from deleted A, B.dbo.man tmpB
where A.a=tmpB.a and A.b=tmpB.b and A.c=tmpB.c
go

create trigger tr_man_insert on man
for insert
as
insert B.dbo.man
select *, 1 from inserted
go

create trigger tr_man_update on man
for update
as
update B.dbo.man tmpB set tmpB.a=inserted.a, tmpB.b=inserted.b, tmpB.c=inserted.c
from inserted, deleted
where tmpB.a=deleted.a and tmpB.b=deleted.b and tmpB.c=deleted.c
go

Nicholasqpl 2007-03-09
  • 打赏
  • 举报
回复
[43.82.54.90] 的DB 连接已经建好了

34,837

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧