高手请回答:::如何用触发器发送消息到特定的应用程序??

ModernBonze 2003-10-17 05:37:00
我想做一个新数据实时记录程序,就时当数据库中的数据每添加一条,就通过触发器发送消息到特定的应用程序(A)中,然后程序(A)执行有关的操作!
...全文
72 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
HenanBoy 2003-10-17
  • 打赏
  • 举报
回复
yujohny(踏网无痕)的观点
的观点就是你必须要得到系统的消息了。不过有时候不能这样做了,特别对于Web这样的程序是很难实现的
你看我有一个比较骚的注意就是说你可以发送一个错误过去就是一个特定的错误消息不就知道了,这样你可以在数据客户端的得到的这个错误的消息的你就知道了是数据已经插入了
qdubit 2003-10-17
  • 打赏
  • 举报
回复
赞同yujohny(踏网无痕)的观点
exec master..xp_cmdshell 'net send 对方ip或机器名 要写的信息!'
伍子V5 2003-10-17
  • 打赏
  • 举报
回复
use model
go
drop proc send_message
go
create proc send_message as begin
create table #tspid(
spid int null,
ecid int null,
status varchar(20) null,
loginname varchar(20) null,
hostname varchar(20) null,
blk bit null,
dbname varchar(20) null,
cmd varchar(20)
)

insert into #tspid(spid,ecid,status,loginname,hostname,blk,dbname,cmd) exec sp_who

create table #userip(id int identity,txt varchar(1000))

--可以得到hostName
declare @cmdStr varchar(100), @hostName varchar(30), @userip varchar(20), @sendstr varchar(100)

declare tspid cursor for select hostname from #tspid where spid>50
open tspid

fetch next from tspid into @hostname
WHILE @@FETCH_STATUS = 0
begin
select @cmdStr='ping '+@hostName
insert into #table(txt) exec master..xp_cmdshell @cmdStr

select @userip=substring(txt,charindex('[',txt)+1,charindex(']',txt)-charindex('[',txt)-1) from #table where id=2

--得到IP地址,也可以不直接用hostName
select @sendstr='net send '+@userip+'Messages!'
exec master..xp_cmdshell @sendstr
fetch next from tspid into @hostname
end

drop table #tspid
drop table #userip
end

go
yujohny 2003-10-17
  • 打赏
  • 举报
回复
举例:exec master..xp_cmdshell 'net send johny 要做事了'
yoki 2003-10-17
  • 打赏
  • 举报
回复
可以这样
每添加一条纪录,触发器往日志中添加描述
然后定时查询日志,如果有新加的纪录就调用程序A执行相关操作
yujohny 2003-10-17
  • 打赏
  • 举报
回复
exec master..xp_cmdshell 'net send 对方ip或机器名 要写的信息!'

22,206

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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