Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Send Mail not passing parameters

Author  Topic 

fezz
Starting Member

12 Posts

Posted - 2010-08-02 : 10:48:23
WHen i create the following SP it sends the email but includes the query as text and not the actual results, any ideas whats up?

Thanks

declare @query_text varchar(8000)
-- Queries the Data
set @query_text = 'SELECT sh.No_ as "No", CONVERT(VARCHAR(106),sh.[Order Date],103) as "Order Date",
sh.[Sell-to Customer Name] as "Customer Name",
CAST(ROUND(SUM(sl.[Outstanding Amount]), 2, 1) AS decimal(18, 2)) as "Outstanding Amount"
FROM servera.dba.dbo.[A$Sales Line] AS sl RIGHT OUTER JOIN
servera.dba.dbo.[A$Sales Header] AS sh ON sh.No_ = sl.[Document No_]
WHERE (sl.[Outstanding Amount] > ''25000'') and sh.[Document Type] = ''1''
GROUP BY sh.No_, sh.[Sell-to Customer Name], sh.[Order Date]
order by OutstandingAmount desc'

BEGIN
exec master..xp_sendmail
@recipients = 'peter@bournemouth.ws',
@subject = 'Sales',
@message = @query_text
END

Pete

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-03 : 02:13:59
try


BEGIN
exec master..xp_sendmail
@recipients = 'peter@bournemouth.ws',
@subject = 'Sales',
@query = @query_text
END


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -