Wednesday, February 27, 2013

send email on specific uses

Hi, i am going to show you how you can email when a table has more records than it should be or you can create the custome code what ever you needed and send an email when you need

DECLARE @test VARCHAR(1000)
SET @test = 'Select top 10 * from sys.messages'
EXEC (@test)
BEGIN
IF @@ROWCOUNT > 20

DECLARE @availableSpace AS FLOAT
DECLARE @alertMessage AS Varchar(4000)

EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'XYZ',
---select * from dbo.sysmail_profile
@recipients = 'name@XYZ.com',--to send group send developers@abc.com--this will send email to all people in group  developers@abc.com
@body = @alertMessage,
@importance = 'High',
@subject = 'testr';
END


ELSE
PRINT' Less '


Thanks

No comments:

Post a Comment

https://blog.sqlauthority.com/2009/06/27/sql-server-fix-error-17892-logon-failed-for-login-due-to-trigger-execution-changed-database-context...