SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 send an email
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

wided
Posting Yak Master

201 Posts

Posted - 02/11/2014 :  06:03:34  Show Profile  Reply with Quote
are there a SQL2012 code to send an email by trigger or stored procedure

thanks

khtan
In (Som, Ni, Yak)

Singapore
17681 Posts

Posted - 02/11/2014 :  20:33:52  Show Profile  Reply with Quote
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
Time is always against us

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 02/12/2014 :  00:00:20  Show Profile  Reply with Quote
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

201 Posts

Posted - 02/18/2014 :  05:20:27  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 02/18/2014 :  13:09:18  Show Profile  Reply with Quote
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

201 Posts

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

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 02/23/2014 :  10:28:52  Show Profile  Reply with Quote
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
Constraint Violating Yak Guru

United Kingdom
451 Posts

Posted - 02/25/2014 :  08:46:50  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000