You are here: Re: Query result sent via e-mail « MsSQL Server « IT news, forums, messages
Re: Query result sent via e-mail

Posted by Jennifer on 05/24/07 19:31

In addition to the other suggestion to use xp_sendmail, you could use
the job scheduler to set it up to run at a specific time each day.
I've got some sample code below that was used for exactly the same
thing. In your stored procedure you'd have to do the formatting in
the Select clause.

DECLARE @rlist varchar(1000)
Declare @Sub nvarchar(60)
Declare @Q nvarchar(100)
Declare @Date1 nvarchar(20)
Declare @Date2 nvarchar(20)

set @Date1 = Convert(nvarchar(12), GetDate() - 2, 101)
set @Date2 = Convert(nvarchar(12), GetDate() - 1, 101)

set @Q = 'EXEC [WIN Support Database]..RebootsReport ''' + @Date1 +
''', ''' + @Date2 + ''''
Select @Sub = 'Reboot Report for ' + @Date1
SELECT @rlist = 'xxx@xx.xxx'
exec master..xp_sendmail @recipients=@rlist,@query=@Q,@subject=@Sub


On May 24, 2:22 am, "Marco Garutti" <marco.garu...@tecnoform.com>
wrote:
> Hi all,
> I've a query running under MS SQLServer2000 (Stored Procedures).
> I'd like to send it's result via e-mail, formatting the output in txt form
> or html form.
> Someone knows how to do it ? Have you got examples of code ?
> Thanks for the advice
>
> Marco Garutti

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация