February 5, 2011 at 5:34 am
I want to query the database for every 15 minutes and see if any record found in the table..if any record found, I want to send to send email to user for each records.
Please help me.
February 5, 2011 at 6:13 am
don't do that with a CLR proc !!
Just schedule a sqlagent job that sends a sp_dbmail when it finds rows.
if exists (select * from yourdb.yourschema.yourtable)
begin
declare @subject varchar(1000)
set @subject = @@servername + ': Count of master sysfiles'
EXEC msdb.dbo.sp_send_dbmail
-- @profile_name = 'yourmailprofile',
@recipients = 'yourreceiver@yourcomp.com',
@execute_query_database='master'
@query = 'SELECT * FROM sys.sysfiles ',
@subject = @subject,
@body='check the data',
@query_result_width = 8000,
@query_result_separator = '',
@attach_query_result_as_file = 1 ,
@query_attachment_filename='deQueryResultFileName.csv',
@append_query_error = 1 ;
end
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
February 7, 2011 at 7:24 pm
Hi, Thanks for reply.
Do you mean to say to set up database mail and configure the SQL. if you can forward me the detail in step by step. I would help me more, I'm new to programming.
February 8, 2011 at 12:17 am
maybe this SSC art can get you started with dbmail http://www.sqlservercentral.com/articles/Administration/introtodatabasemailinsql2005/2197/
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply