22,210
社区成员
发帖
与我相关
我的任务
分享
set @SQL='declare H_t cursor for select Ltel from customsname where customersname in ('+ @sendto+')'
--你把它改成下面的试一试
set @SQL='declare H_t cursor for select Ltel from customsname where customersname in ('''+ @sendto+''')'
if object_id('dbo.notifyinfo','tr') is not null
drop trigger dbo.notifyinfo
go
create trigger notifyinfo
on dbo.messageitemsnow
after insert
as
begin
declare @msgid int
declare @note varchar(max)
declare @sendto varchar(max)
declare @tel nchar(11)
declare @SQL Varchar(2000)
select msgid,mstype+':'+msnote+msend note,sendto into # from messageitemsnow where flag=1
declare H_settle Cursor keyset for
select * from # where flag=1
open h_settle
fetch next from h_settle into @msgid,@note,@sendto
while @@fetch_status=0
begin
set @SQL='declare H_t cursor for select Ltel
from customsname where customersname in ('+ @sendto+')'
exec(@SQL)
open h_t
fetch next from h_t into @tel
while(@@fetch_status=0)
begin
insert into to_ex_sms(teln,msg,sys_code,sys_name_id,sys_subname_id,msgid)
values(@tel,@note,'0','0','0020',@msgid)
fetch next from h_t into @tel
end
close h_t
deallocate h_t
update messageitemsnow set flag=0 where msgid=@msgid
fetch next from h_settle into @msgid,@note,@sendto
end
close h_settle
deallocate h_settle
drop table #
end
try