短訊息發送的SQL過程

來源:互聯網
上載者:User

ALTER PROCEDURE [dbo].[SP_SMS_SetMsgReceiver]
 @MsgID      int,
 @Receivers           varchar(5000),
 @MobileNo     varchar(5000),
 @Type      int
           
/*

============================================================
功能: 短訊息發送
參數:
 @MsgID                  int   : 訊息ID
 @Receivers      varchar(5000), : 接收者字串,用逗號相隔
 @MobileNo      varchar(5000), : 手機號碼,用逗號相隔
 @Type                   int    ; 1站內使用者 2站外使用者
注意:    @Receivers與@MobileNo必須一一對應
============================================================

*/

AS
SET NOCOUNT ON
DECLARE @Receiver varchar(300)
DECLARE @Mobile varchar(300)

WHILE LEN(@Receivers)>0
BEGIN
 --如果不是最後一次
 IF(charindex(',',@Receivers)>0)
 BEGIN
 --截取逗號前資料
 SET @Receiver = substring(@Receivers,1,charindex(',',@Receivers)-1)
 --判斷手機號碼是否為空白
 IF(LEN(@MobileNo)>0)
  SET @Mobile     = substring(@MobileNo,1,charindex(',',@MobileNo)-1)
 ELSE
  SET @Mobile=''
 --剪下字串
 SET @Receivers = substring(@Receivers,charindex(',',@Receivers)+1,LEN(@Receivers)) 
 --判斷手機號碼是否為空白
 IF(LEN(@MobileNo)>0)
  SET @MobileNo  = substring(@MobileNo,charindex(',',@MobileNo)+1,LEN(@MobileNo)) 
 ELSE
  SET @MobileNo=''
 INSERT INTO
      UDS_SMS_Receiver
   VALUES
   (@MsgID,@Receiver,@Mobile,@Type,0) 
 --print @Receiver
 --print @Mobile
 END
 ELSE
 BEGIN
  --PRINT @Receivers
  --PRINT @MobileNo
 INSERT INTO
   UDS_SMS_Receiver
   VALUES
   (@MsgID,@Receivers,@MobileNo,@Type,0)  
  BREAK
 END

END

SET NOCOUNT OFF

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.