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
 Import/Export (DTS) and Replication (2000)
 Email

Author  Topic 

JonahMk2
Starting Member

21 Posts

Posted - 2004-10-25 : 04:45:37
I have produced a query which, when run gives me a set of results. Is it possible for me to Email these results through DTS to the relevant people. I don't know which way to go about it.

Should I run 1 DTS package to put the results into a table and then email the results?

Access Query (Access Query Returns Results)


DTS Package Executed (DTS Pump Extracts results from Access)


Results Returned in Table (Results are Put into a Table)


Table Emailed to Relevant Users (The table is then Emailed to Certain Users)

Or can I simply transfer the table to an email using the 'Transfer SQL Server Objects'?


Please help

Thanks

nr
SQLTeam MVY

12543 Posts

Posted - 2004-10-25 : 09:16:34
You can just code an xp_sendmail with an attachment of a select from the table.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

JonahMk2
Starting Member

21 Posts

Posted - 2004-10-25 : 09:32:30
How do you attach the xp_sendmail to the Select from Statement?
Is it like this?

Select * FROM PartUpdate

EXEC master..xp_sendmail 'me@meltd.com',

'New Part Numbers Update.'

I've tried this but it just sends me 'New Part Numbers Update' in the mail, how can I include the results?

Thanks
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-10-25 : 11:21:53
have a look at xp_sendmail in bol

exec master..xp_sendmail @recipients='...', @subject='...', @message='...', @attach_results='true',@query='select * from mydb.dbo.mytbl'

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

JonahMk2
Starting Member

21 Posts

Posted - 2004-10-26 : 05:52:12
This is the code:

EXEC master..xp_sendmail @recipients = 'me@meltd.com',
@query = 'SELECT * FROM NewPartNos..PartIDUpdate',
@subject = 'New Part Numbers',
@message = 'The contents of New PartIDUpdate:',
@attach_results = 'TRUE', @width = 250

This is the Error:
Invalid object name 'NewPartNos..Partidupdate'.

I have created a Database called 'NewPartNos' I have pumped data into a table called 'PartIDUpdate'. It still does not work. What else could I be doing wrong??
Go to Top of Page
   

- Advertisement -