/*============================================================ 功能: 手机短消息发送 参数: @Sender varchar(50) : 发送者用户名 @RecipientMobileNo varchar(20) : 接收者手机号码 @Content varchar(255) : 信息内容 @sendtime datetime ; 发送时间 @RepeatTimes int ; 重复发送分钟数 @RepeatPeriod int ; 重复间隔时间(以分钟为单位) ============================================================*/AS SET NOCOUNT ON DECLARE @MobileNo varchar(30) WHILE LEN(@RecipientMobileNo)>0 BEGIN --如果不是最后一次 IF(charindex(',',@RecipientMobileNo)>0) BEGIN --截取逗号前数据 SET @MobileNo = substring(@RecipientMobileNo,1,charindex(',',@RecipientMobileNo)-1) --剪切字符串 SET @RecipientMobileNo = substring(@RecipientMobileNo,charindex(',',@RecipientMobileNo)+1,LEN(@RecipientMobileNo)) INSERT INTO UDS_SMS_MobileMsgSendBuffer (Sender,RecipientMobileNo,Content,SendTime,RepeatTimes,RepeatPeriod) VALUES (@Sender,@MobileNo,@Content,@Sendtime,@RepeatTimes,@RepeatPeriod) print @MobileNo --print @Mobile END ELSE BEGIN --PRINT @Receivers --PRINT @MobileNo INSERT INTO UDS_SMS_MobileMsgSendBuffer (Sender,RecipientMobileNo,Content,SendTime,RepeatTimes,RepeatPeriod) VALUES (@Sender,@RecipientMobileNo,@Content,@Sendtime,@RepeatTimes,@RepeatPeriod) BREAK END ENDSET NOCOUNT OFF GO
然后在程序中使用以下语句执行脚本:shell app.path & "\osql -H 机器名 -U SQL账号 -P SQL登录密码 -i D:\data.sql"其中osql是SQL中的工具,可以这个工具打包到你的程序中.打包要用第三方的打包工具可以执行.用VB自带的不行,除非在程序运行时可以,但要注意判断是否为第一运行.
-----------------------------------------------------------------CREATE PROCEDURE SP_SMS_SaveMobileMsgToBuffer
@Sender varchar(50),
@RecipientMobileNo varchar(255),
@Content varchar(255),
@Sendtime datetime,
@RepeatTimes int,
@RepeatPeriod int
/*============================================================
功能: 手机短消息发送
参数:
@Sender varchar(50) : 发送者用户名
@RecipientMobileNo varchar(20) : 接收者手机号码
@Content varchar(255) : 信息内容
@sendtime datetime ; 发送时间
@RepeatTimes int ; 重复发送分钟数
@RepeatPeriod int ; 重复间隔时间(以分钟为单位)
============================================================*/AS
SET NOCOUNT ON
DECLARE @MobileNo varchar(30)
WHILE LEN(@RecipientMobileNo)>0
BEGIN
--如果不是最后一次
IF(charindex(',',@RecipientMobileNo)>0)
BEGIN
--截取逗号前数据
SET @MobileNo = substring(@RecipientMobileNo,1,charindex(',',@RecipientMobileNo)-1)
--剪切字符串
SET @RecipientMobileNo = substring(@RecipientMobileNo,charindex(',',@RecipientMobileNo)+1,LEN(@RecipientMobileNo))
INSERT INTO
UDS_SMS_MobileMsgSendBuffer (Sender,RecipientMobileNo,Content,SendTime,RepeatTimes,RepeatPeriod)
VALUES
(@Sender,@MobileNo,@Content,@Sendtime,@RepeatTimes,@RepeatPeriod)
print @MobileNo
--print @Mobile
END
ELSE
BEGIN
--PRINT @Receivers
--PRINT @MobileNo
INSERT INTO
UDS_SMS_MobileMsgSendBuffer (Sender,RecipientMobileNo,Content,SendTime,RepeatTimes,RepeatPeriod)
VALUES
(@Sender,@RecipientMobileNo,@Content,@Sendtime,@RepeatTimes,@RepeatPeriod)
BREAK
END
ENDSET NOCOUNT OFF
GO