sql - How to email query output -


I have a basic query, and I want to email the results. How can I do this at the question level? So if my query is:

  SELECT Store_Id, Paid_Out_Amount, Paid_Out_Comment, Paid_Out_Datetime, Update_UserName FROM Paid_Out_Tb WHERE (Store_Id = 1929) or (Paid_Out_Amount> 50) and (Paid_Out_Datetime Convert (DATETIME, 2012-06-01 00:00:00 ', 102) and convert (DATETIME,' 2012-06-30 00:00:00 ', 102))   

How do I email Production? I have a process of sending email through SMTP and parameter @ Frame @ ll @ subject and @body ... that works .. I How will the results of the body query?

  Set aside from QUOTED_IDENTIFIER, create ANSI_NULLS process on set GO [dbo]. [Sp_SQLNotify] @From varchar (100), @To varchar (100), @Subject Varchar (100) = "", @ body varchar (4000) = "test" / ************ **************************************************************************************************** ******* ******************************************************************************************* **************************************************************************************************** ********************* similarity. All mail configurations are hard-coded in the stored procedure. Where necessary, comments are added to the stored procedure. The references for CDOSYS items are on the following MSDN Web site: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_messaging.asp **** * ************************************************* * **************** / as stated @iMsg declared integer declared declared @hr @source varchar (255) declare @description varchar (500) @output varchar (1000) int - * ************************************************ ***** Send '@ Aimjiti OAT - ******************** configuring ************* message object ****************** configure remote SMTP server - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ Cdosys / html / _cdosys_schema_confi Guration_sendusing.asp EXEC @hr = sp_OASetProperty @iMsg, 'configuration.field ("http: //schemas.microsoft.com/cdo/configuration/sendusing").Value', '2' - This server name or IP address is configured To - Change your SMTP server name or IP to MailServerName EXEC @hr = sp_OASetProperty @iMsg, 'Configuration. Fields ("http://schemas.microsoft.com/cdo/configuration/smtpserver"). Value, '10.1.1.10 '- Save in Configuration Message Object. EXEC @hr = sp_OAMethod @iMsg, 'Configuration. Files. Update ', empty - Set e-mail parameters EXEC @hr = sp_OASetProperty @iMsg,' to ', @To EXEC @hr = sp_OASetProperty @iMsg,' to ', @FROM EXEC @hr = sp_OASetProperty @iMsg,' Subject ' , @ Subject - If you are using HTML e-Mail, use 'HTMLBody' instead of 'TextBody' EXEC @hr = sp_OASetProperty @iMsg, 'TextBody', @Body EXEC @hr = sp_OAMethod @iMsg, 'Send ', Zero - sample error handling. If @hr & lt; & Gt; 0hr start selection of EXEC @hr = sp_OAGetErrorInfo zero, @source out, @description out @hr = 0 BEGIN selection @output = 'source:' + @source Print @output @output = 'Description:' @ @ Description print @output END or print 'sp_OAGetErrorInfo failed.' Return end END - clean up made items EXEC @hr = sp_OADestroy @imsg Print 'Mail Sent!' Go set aside from QUOTED_IDENTIFIER ANSI_NULLS on set GO   

This process is I'm using to send mail ... which works ... I just have to do it Want to add a place in the afterwards send the result of the question ... can this be done easily in the process?

Use SQL Server PowerShell Pack.

(It is derived from the above, but to clarify something, he says: SQL Server 2008 client components are required (the express must be fine), but it's SQL Server 2000 database () Can work with.)

Comments