SQL/Answer Detail

How to send message using database

Ankit tewari
Ankit tewari
34 Points
17 Posts

how can Send SMS using  stored procedures from SQL Server 2008 

Total Answered: 2
Total Marked As Answer: 0
Posted On: 30-Jan-2018 10:35
Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul Maurya
Moderator
1146 Points
208 Posts
 
 
Posted On: 31-Jan-2018 03:29

There is no in-build method to sending SMS but you can use external xmlhttp api in store procedure. See following thread for more detail http://www.niceonecode.com/Q-A/SQL/Query/Send-SMS--Email-Using-Backend-/20396

Feel free to ask if any issue.

nik
nik
Member
40 Points
10 Posts
 
 
Posted On: 01-Feb-2018 23:46

Use following, where @sUrl is SMS send api url with parameters:

Create PROCEDURE SP_CallWebService @sUrl NVARCHAR(MAX)
AS
BEGIN  
  DECLARE @iReq INT,
    @hr INT
  DECLARE @errorSource VARCHAR(8000)
  DECLARE @errorDescription VARCHAR(8000)
  DECLARE @sResponse NVARCHAR(MAX)
  EXEC @hr = sp_OACreate 'Microsoft.XMLHTTP',@iReq OUT

  EXEC @hr = sp_OAMethod @iReq,'Open',NULL,'GET',@sUrl,'false'
  if @hr<>0
        print ' Failed in sp_OAMethod open'
  EXEC @hr = sp_OAMethod @iReq,'send'
  if @hr<>0
        print ' Failed in sp_OAMethod send'
  BEGIN
    set @hr=0
    EXEC @hr = sp_OAGetProperty @iReq,'responseText',@sResponse OUT
    if @hr<>0
        print ' Failed in sp_OAGetProperty'
  END
  
  EXEC sp_OADestroy @iReq
  EXEC sp_OADestroy @hr
END
GO

Blog

Active User (2)

 Log In to Chat