22,301
社区成员




if exists(select * from sysobjects where name='Result' )
drop table Result
select LineNum as 线路,SIM as 号码 into Result from UV_MsgInbox t1
where t1.MsgArrivedTime >= dateadd(minute,-5,getdate())
and MsgTitle='外接电源断电,启动内置电源'
and not exists(select * from UV_MsgInbox t2
where t2.Sender = t1.SIM
and t2.MsgArrivedTime >= dateadd(minute,-5,getdate())
and t2.MsgTitle ='恢复正常供电')
group by t1.SIM,t1.LineNum
select 线路 from Result group by 线路 having count(DISTINCT 号码)>=2
if exists(select 线路 from Result group by 线路 having count(DISTINCT 号码)>=2)
begin
declare @receiver varchar(500)
set @receiver='13737740287,15878359061,15812405921'
if exists (select * from UV_MsgInbox t1 where t1.MsgType=1 and t1.MsgArrivedTime >= dateadd(minute,-5,getdate())
and t1.sender in (select 号码 from Result group by 号码 having count(DISTINCT 号码)>=2))--后半括号中子查询不对
if exists(select * from sysobjects where name='Result' )
drop table Result
select LineNum as 线路,SIM as 号码 into Result from UV_MsgInbox t1 where t1.MsgArrivedTime >= dateadd(minute,-5,getdate()) and MsgTitle='外接电源断电,启动内置电源' and not exists(select * from UV_MsgInbox t2 where t2.Sender = t1.SIM
and t2.MsgArrivedTime >= dateadd(minute,-5,getdate())
and t2.MsgTitle ='恢复正常供电')
group by t1.SIM,t1.LineNum
select 线路 from Result group by 线路 having count(DISTINCT 号码)>=2
if exists(select 线路 from Result group by 线路 having count(DISTINCT 号码)>=2)
begin
--declare @receiver varchar(500)
--set @receiver='13737740287,15878359061,15812405921'
if exists (select * from UV_MsgInbox t3 where t3.MsgType=1 and t3.MsgArrivedTime >= dateadd(minute,-5,getdate()) and t3.sender in (select 号码 from Result group by 号码))--后半括号中子查询不对
begin
......后面省略
if exists(select * from sysobjects where name='Result' )
drop table Result
select LineNum as 线路,SIM as 号码 into Result from UV_MsgInbox t1 where t1.MsgArrivedTime >= dateadd(minute,-5,getdate()) and MsgTitle='外接电源断电,启动内置电源' and not exists(select * from UV_MsgInbox t2 where t2.Sender = t1.SIM
and t2.MsgArrivedTime >= dateadd(minute,-5,getdate())
and t2.MsgTitle ='恢复正常供电')
group by t1.SIM,t1.LineNum
select 线路 from Result group by 线路 having count(DISTINCT 号码)>=2
if exists(select 线路 from Result group by 线路 having count(DISTINCT 号码)>=2)
begin
--declare @receiver varchar(500)
--set @receiver='13737740287,15878359061,15812405921'
if exists (select * from UV_MsgInbox t3 where t3.MsgType=1 and t3.MsgArrivedTime >= dateadd(minute,-5,getdate()) and t3.sender in (select SIM as 号码 from UV_MsgInbox t1 where t1.MsgArrivedTime >= dateadd(minute,-5,getdate())
and MsgTitle='外接电源断电,启动内置电源'
and not exists(select * from UV_MsgInbox t2
where t2.Sender = t1.SIM
and t2.MsgArrivedTime >= dateadd(minute,-5,getdate())
and t2.MsgTitle ='恢复正常供电')
group by t1.SIM,t1.LineNum ))--后半括号中子查询不对
begin
......下面内容省略
if exists (select * from UV_MsgInbox t1 where t1.MsgType=1 and t1.MsgArrivedTime >= dateadd(minute,-5,getdate())
and exists (select 号码 from Result where t.sender=result.号码 group by 号码 having count(DISTINCT 号码)>=2))
if exists(select 线路 from Result group by 线路 having count(DISTINCT 号码)>=2)
begin
declare @receiver varchar(500)
set @receiver='13737740287,15878359061,15812405921'
if exists (select * from UV_MsgInbox t1 where t1.MsgType=1 and t1.MsgArrivedTime >= dateadd(minute,-5,getdate()
and t1.sender in (select 号码 from Result group by 号码 having count(DISTINCT 号码)>=2))