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
 SQL Server Development (2000)
 What is the best way of looping thru a temp table

Author  Topic 

filf
Yak Posting Veteran

67 Posts

Posted - 2001-07-27 : 07:19:46
I have an application which is going to utilise the feature documented in: Sending SMTP Mail using a Stored Procedure: http://www.sqlteam.com/item.asp?ItemID=5003 <-- this article is the nuts by the way Merkin, I have been looking to do something like this for ages cos we don't have sqlMail installed.
I also want to eliminate the use of cursors if at all possible, I know how to do this as a cursor but want advice as to whether the way I plan to things is the best/right approach.

1. insert all data into tempTable
2. get [n] - the rowcount for the tempTable
3. create COM object referencing a mail component
4. loop through tempTable n times calling each row individually by its tempTableId=n
5. format email content with tempTable row data then call the sendMail method for the COM object I setup.
6. on completion write a record of the job somewhere and kill the tempTable and any created objects



Is this the right way to go about things, it would require multiple selects though. Also how can I create global variables that I can pass between stored procedures?

Any help is greatfully accepted.




Edited by - filf on 07/27/2001 07:39:14
   

- Advertisement -