USE [master]
GO

/****** Object:  StoredProcedure [dbo].[rkur_sendsms_job_status]    Script Date: 08/18/2015 10:10:59 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:                    Ruslan Kurianov
-- Create date: 2014-12-19
-- Description:          agent mssql job emiltosms
-- version: 0.1
-- =============================================
CREATE PROCEDURE [dbo].[rkur_sendsms_job_status]
          -- Add the parameters for the stored procedure here
@text nvarchar(70)
AS
BEGIN
          -- SET NOCOUNT ON added to prevent extra result sets from
          -- interfering with SELECT statements.
          SET NOCOUNT ON;
          if len(@text)<=0
                              begin
                                        print 'не указан текст сообщения'
                                        print ' '
                              end
                              ELSE
                              BEGIN
                                        -- списки рассылки
                                        declare @all nvarchar(128)
                                        declare @dba nvarchar(128)
                                        -- email
                                        declare @recip nvarchar(64)
                                        declare @sub nvarchar(256)
                                        declare @body nvarchar(256)
                                        --declare @text nvarchar(70)
                                        -- список получателей
                                        declare @esys nvarchar(32)
                                        declare @atom nvarchar(11)
                                        declare @megu nvarchar(11)
                                        declare @pshe nvarchar(11)
                                        declare @rkur nvarchar(11)
                                        -- Настройки письма
                                        set @esys = '7573b91324e28717'
                                        set @recip = 'sms@massreach.com'
                                        set @atom ='7*********2'
                                        set @megu ='7*********3'
                                        set @pshe ='7*********7'
                                        set @rkur ='7*********1'
                                        set @text = @text+'.'+cast(getdate() as nvarchar(24))
                                        -- собираем рассылки
                                        set @all = @atom+','+@megu+','+@pshe+','+@rkur
                                        set @dba = @rkur
                                        set @sub = @esys+' '+@all
                                        set @body = '[SENDER]AIFU[/SENDER][SMS]'+@text+'[/SMS]'
                                        --print @sub
                                        --print @body

                                        EXEC msdb.dbo.sp_send_dbmail
                                                  @profile_name = 'Atrans',
                                                  @recipients = @recip,
                                                  @subject = @sub,
                                                  @body = @body
                              END
END

GO

 

Добавить комментарий

Навигация по записям