osmansays,
Combine a trigger and a stored procedure to send a email on updates
--------------------------------
Procedure like :
Create Procedure sp_SMTPMail
@.SenderName varchar(100),
@.SenderAddress varchar(100),
@.RecipientName varchar(100),
@.RecipientAddress varchar(100),
@.Subject varchar(200),
@.Body varchar(8000),
@.MailServer varchar(100) = 'localhost'
AS
SET nocount on
declare @.oMail int
declare @.resultcode int
EXEC @.resultcode = sp_OACreate 'SMTPsvg.Mailer', @.oMail OUT
if @.resultcode = 0
BEGIN
EXEC @.resultcode = sp_OASetProperty @.oMail, 'RemoteHost', @.mailserver
EXEC @.resultcode = sp_OASetProperty @.oMail, 'FromName', @.SenderName
EXEC @.resultcode = sp_OASetProperty @.oMail, 'FromAddress', @.SenderAddress
EXEC @.resultcode = sp_OAMethod @.oMail, 'AddRecipient', NULL, @.RecipientName, @.RecipientAddress
EXEC @.resultcode = sp_OASetProperty @.oMail, 'Subject', @.Subject
EXEC @.resultcode = sp_OASetProperty @.oMail, 'BodyText', @.Body
EXEC @.resultcode = sp_OAMethod @.oMail, 'SendMail', NULL
EXEC sp_OADestroy @.oMail
END
SET nocount off
--------------------------------
Trigger like :
CREATE TRIGGER trgDataChanged on tblData
AFTER UPDATE
AS
BEGIN
exec sp_SMTPMail @.SenderName='me', @.SenderAddress='me@.somewhere.com', @.RecipientName = 'Someone', @.RecipientAddress = 'someone@.someplace.com', @.Subject='SQL Data Change', @.body='data in table tblData has been changed'
END
--------------------------------
If you also want to track the changes you can either translate the query to simple data or show the data that is changed but to view that you need to walk through the recordset with for instance a cursor.
Peter
Showing posts with label notified. Show all posts
Showing posts with label notified. Show all posts
Friday, March 23, 2012
How can I be notified when record is updated
I want to build an windows application by using a visual C# to Notify the user that his data in the database had been changed ..such like "New Message In Your Mail Box Alert"..So I need to know if there is way that to let the SQL Server send a notify (just like Trigger) ..
Friday, March 9, 2012
How are you notified of mssql patches?
Hi,
Might be a strange question, but I'm struggeling with it for a while..
Is there any website/newsletter/newsfeed, that just informs about new SQL
Server (2000 and 2005) patches?
With the Security Bulletin I don't get all fixes, just a few ones - at the
moment I always actively search for updates to prepare a sql server
maintenance and I would like to be notified about every patch regarding sql
server 2000 or sql server 2005.
Thanks and regards
Andreas
Hi Ben,
thanks for your answer - that's exactly what I searched for :-)
regards
Andreas
Might be a strange question, but I'm struggeling with it for a while..
Is there any website/newsletter/newsfeed, that just informs about new SQL
Server (2000 and 2005) patches?
With the Security Bulletin I don't get all fixes, just a few ones - at the
moment I always actively search for updates to prepare a sql server
maintenance and I would like to be notified about every patch regarding sql
server 2000 or sql server 2005.
Thanks and regards
Andreas
Hi Ben,
thanks for your answer - that's exactly what I searched for :-)
regards
Andreas
How are you notified of mssql patches?
Hi,
Might be a strange question, but I'm struggeling with it for a while..
Is there any website/newsletter/newsfeed, that just informs about new SQL
Server (2000 and 2005) patches?
With the Security Bulletin I don't get all fixes, just a few ones - at the
moment I always actively search for updates to prepare a sql server
maintenance and I would like to be notified about every patch regarding sql
server 2000 or sql server 2005.
Thanks and regards
AndreasI find
[url]http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx[/ur
l] a good source of what patches are available..
In terms of knowing stuff like when sp's are released I rely on my rss
reader, I have a fair few feeds set up and they soon let you know when
something has come out.
"Andreas B" wrote:
> Hi,
> Might be a strange question, but I'm struggeling with it for a while..
> Is there any website/newsletter/newsfeed, that just informs about new SQL
> Server (2000 and 2005) patches?
> With the Security Bulletin I don't get all fixes, just a few ones - at the
> moment I always actively search for updates to prepare a sql server
> maintenance and I would like to be notified about every patch regarding sq
l
> server 2000 or sql server 2005.
> Thanks and regards
> Andreas|||Hi Ben,
thanks for your answer - that's exactly what I searched for :-)
regards
Andreas
Might be a strange question, but I'm struggeling with it for a while..
Is there any website/newsletter/newsfeed, that just informs about new SQL
Server (2000 and 2005) patches?
With the Security Bulletin I don't get all fixes, just a few ones - at the
moment I always actively search for updates to prepare a sql server
maintenance and I would like to be notified about every patch regarding sql
server 2000 or sql server 2005.
Thanks and regards
AndreasI find
[url]http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx[/ur
l] a good source of what patches are available..
In terms of knowing stuff like when sp's are released I rely on my rss
reader, I have a fair few feeds set up and they soon let you know when
something has come out.
"Andreas B" wrote:
> Hi,
> Might be a strange question, but I'm struggeling with it for a while..
> Is there any website/newsletter/newsfeed, that just informs about new SQL
> Server (2000 and 2005) patches?
> With the Security Bulletin I don't get all fixes, just a few ones - at the
> moment I always actively search for updates to prepare a sql server
> maintenance and I would like to be notified about every patch regarding sq
l
> server 2000 or sql server 2005.
> Thanks and regards
> Andreas|||Hi Ben,
thanks for your answer - that's exactly what I searched for :-)
regards
Andreas
How are you notified of mssql patches?
Hi,
Might be a strange question, but I'm struggeling with it for a while..
Is there any website/newsletter/newsfeed, that just informs about new SQL
Server (2000 and 2005) patches?
With the Security Bulletin I don't get all fixes, just a few ones - at the
moment I always actively search for updates to prepare a sql server
maintenance and I would like to be notified about every patch regarding sql
server 2000 or sql server 2005.
Thanks and regards
AndreasI find
http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx a good source of what patches are available..
In terms of knowing stuff like when sp's are released I rely on my rss
reader, I have a fair few feeds set up and they soon let you know when
something has come out.
"Andreas B" wrote:
> Hi,
> Might be a strange question, but I'm struggeling with it for a while..
> Is there any website/newsletter/newsfeed, that just informs about new SQL
> Server (2000 and 2005) patches?
> With the Security Bulletin I don't get all fixes, just a few ones - at the
> moment I always actively search for updates to prepare a sql server
> maintenance and I would like to be notified about every patch regarding sql
> server 2000 or sql server 2005.
> Thanks and regards
> Andreas|||Hi Ben,
thanks for your answer - that's exactly what I searched for :-)
regards
Andreas
Might be a strange question, but I'm struggeling with it for a while..
Is there any website/newsletter/newsfeed, that just informs about new SQL
Server (2000 and 2005) patches?
With the Security Bulletin I don't get all fixes, just a few ones - at the
moment I always actively search for updates to prepare a sql server
maintenance and I would like to be notified about every patch regarding sql
server 2000 or sql server 2005.
Thanks and regards
AndreasI find
http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx a good source of what patches are available..
In terms of knowing stuff like when sp's are released I rely on my rss
reader, I have a fair few feeds set up and they soon let you know when
something has come out.
"Andreas B" wrote:
> Hi,
> Might be a strange question, but I'm struggeling with it for a while..
> Is there any website/newsletter/newsfeed, that just informs about new SQL
> Server (2000 and 2005) patches?
> With the Security Bulletin I don't get all fixes, just a few ones - at the
> moment I always actively search for updates to prepare a sql server
> maintenance and I would like to be notified about every patch regarding sql
> server 2000 or sql server 2005.
> Thanks and regards
> Andreas|||Hi Ben,
thanks for your answer - that's exactly what I searched for :-)
regards
Andreas
Subscribe to:
Posts (Atom)