Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 send an email

Author  Topic 

wided
Posting Yak Master

218 Posts

Posted - 2014-02-11 : 06:03:34
are there a SQL2012 code to send an email by trigger or stored procedure

thanks

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-02-11 : 20:33:52
setup http://technet.microsoft.com/en-us/library/ms175887%28v=sql.105%29.aspx

and you can send email using http://technet.microsoft.com/en-us/library/ms190307%28v=sql.105%29.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-02-12 : 00:00:20
you can use sp_send_dbmail
Why do you want to do it from trigger? Can you tell your exact requirement?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

wided
Posting Yak Master

218 Posts

Posted - 2014-02-18 : 05:20:27
validation of a document, I need to send a notification to one or more persons
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-02-18 : 13:09:18
why use trigger for validation? why not write rules inside a procedure?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

wided
Posting Yak Master

218 Posts

Posted - 2014-02-20 : 08:32:36
Yes I can also use a procedure
can you tell me how?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-02-23 : 10:28:52
quote:
Originally posted by wided

Yes I can also use a procedure
can you tell me how?


I cant without knowing any of your rules!
the stub will look like below

CREATE PROC ValidateBusinessRules
@param1 ...
AS
..
GO


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

sz1
Aged Yak Warrior

555 Posts

Posted - 2014-02-25 : 08:46:50
Try this!


IF OBJECT_ID('sd_Trigger', 'TR') IS Not Null
Drop Trigger sd_Trigger
GO
Create Trigger sd_Trigger
On dbo.Test
After Update, Insert, Delete
AS
exec msdb.dbo.sp_send_dbmail
@profile_name = 'profile name goes here',
@recipients = 'someemailaddress@domain.co.uk',
@body = 'hello world',
@subject = 'test email';
GO

SZ1
Please help me to enable me to help others!
Go to Top of Page
   

- Advertisement -