Send SMS from a trigger

  • Al Siks

    Old Hand

    Points: 360

    Comments posted to this topic are about the item Send SMS from a trigger


    Got SQL Server? Manage It with Siccolo

  • Tom Munghono

    Valued Member

    Points: 71

    I found your article quite interesting int approach to using SQL svr as a broadcast point. Thanx.

  • xuyendarling2006

    SSC Rookie

    Points: 39

    Hi. I'm from VietNam. I've read your article and very excited about it. But when I do like you, I can't send a message to a mobiphone or e-mail. I think your SMS provider's rules not suitable to my country but I can't solve that problem. Can you help me? Phone number in my country have format like 840958149760. 84 is the code of my country. 095 is the code of the provider. 8149760 is the phone number. :). Can you contact with me throught my e-mail (kimxuyen.it@gmail.com) or yahooID: kimxuyenit? Thanks!

  • MackamMagic

    SSC Veteran

    Points: 224

    Need to be pretty careful with this trigger.

    Consider if the call to exec master.xp_sendMail .... fails.

    This is a trigger - an error will cause an automatic rollback of the transaction in which the trigger was fired. Not only will the email/sms not be send but also the action which caused it to be raised - i.e. the insert into the table will not happen. If this insert was called from e.g. a stored proc then whatever was in there would also roll back.

    I had a very similar problem many moons ago with a USERS table for a web site that had a trigger to send a rgistration email - lo and behold if exchange falls over or we can't connect to it then not only do they not receive their registration email but they also don't get registered on the site - i.e. no row appears in the USERS table. Very dangerous.

  • MackamMagic

    SSC Veteran

    Points: 224

    Oh and btw SQL 2005's database mail is now asynchronous therefore we no longer have the same issue in 2005.

  • roy.it2007

    SSC Rookie

    Points: 33

    .... i m an pl/sql developer

    working for a coperative banks

    now the bank pepoles want to send sms to their customer when they do some transaction

    whether it is credited or debited

    .. bank is using a oracle database to store the information

    about all transaction and using window OS

    after every transaction it insert a row in a dotr010 (transaction table)

    sir i had developed a standalone software to send sms usning AT commands in VB 6.0

    but sir it is not automatically trigger a sms to customer this utility not send sms untill it is not run by bank pepoles

    i need your help

    my banking software is completely

    window based

    i need ur help to get know

    1. how to communicate GSM modem through oracle (procedure,pl/sql)

    2. how the sms is triggered when one row is inserted in a transaction tabel

    3. and how to maintain log file

    this all only by using oracle no interface

    thanks for kind time

    i hope you pepole reply soon

    i need it

    regard

    atul

  • Jack Corbett

    SSC Guru

    Points: 184296

    I just want to mention that I agree with MackamMagic, that you need to be very careful when doing something like this in a trigger, in fact I recommend against it, although as MackamMagic also mentions this is not as much an issue with SQL Server 2005. If you need to do any action outside the database I recommend queuing the data using a trigger and have a job or windows service that does the action.

    The other thing is that are you sure you only want to send an email or SMS out when only 1 row is updated? At the least shouldn't someone be notified that a mass update was done?


    Jack Corbett Consultant Straight Path Solutions Dont let the good be the enemy of the best. -- Paul FlemingAt best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at workCheck out these links on how to get faster and more accurate answers: Forum Etiquette: How to post data/code on a forum to get the best helpNeed an Answer? Actually, No ... You Need a QuestionHow to Post Performance Problems[/url]Crosstabs and Pivots or How to turn rows into columns Part 1[/url][url url=http://www.sqlservercent

  • bsr.anwar

    SSC Journeyman

    Points: 91

    I created the trigger successfully but when I tried to update the table the query doesn't execute it prints out

    error stating that

    Msg 15281, Level 16, State 1, Procedure xp_sendmail, Line 1

    SQL Server blocked access to procedure 'sys.xp_sendmail' of component 'SQL Mail XPs' because this component is

    turned off as part of the security configuration for this server. A system administrator can enable the use of 'SQL

    Mail XPs' by using sp_configure. For more information about enabling 'SQL Mail XPs', see "Surface Area

    Configuration" in SQL Server Books Online.

    Any help would be more appreciated am beginner to sqlserver

  • Jack Corbett

    SSC Guru

    Points: 184296

    bsr.anwar (5/8/2014)


    I created the trigger successfully but when I tried to update the table the query doesn't execute it prints out

    error stating that

    Msg 15281, Level 16, State 1, Procedure xp_sendmail, Line 1

    SQL Server blocked access to procedure 'sys.xp_sendmail' of component 'SQL Mail XPs' because this component is

    turned off as part of the security configuration for this server. A system administrator can enable the use of 'SQL

    Mail XPs' by using sp_configure. For more information about enabling 'SQL Mail XPs', see "Surface Area

    Configuration" in SQL Server Books Online.

    Any help would be more appreciated am beginner to sqlserver

    You shouldn't be using SQL Mail you should be using Database Mail.


    Jack Corbett Consultant Straight Path Solutions Dont let the good be the enemy of the best. -- Paul FlemingAt best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at workCheck out these links on how to get faster and more accurate answers: Forum Etiquette: How to post data/code on a forum to get the best helpNeed an Answer? Actually, No ... You Need a QuestionHow to Post Performance Problems[/url]Crosstabs and Pivots or How to turn rows into columns Part 1[/url][url url=http://www.sqlservercent

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply