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 2005 Forums
 Transact-SQL (2005)
 Can We loop query result of For xml path('td')

Author  Topic 

rafeequddin_ahmed
Starting Member

23 Posts

Posted - 2008-07-17 : 06:45:49
Hi,
I m using this query .
Declare @value xml
Set @value=(select top 10[email] from tbl_users for xml path('td'))
select @value
and it is giving me the following result.

<td><email>arafeeq@abc.com</email></td><td><email>stanikella@ghi.com</email></td><td><email>pramachandruni@jjj.com</email></td><td><email>spuladas@gg.com</email></td><td><email>dsd@ghjgh.dsjdg</email></td><td><email>dfg@hjg.ddd</email></td><td><email>tseshasayi@ff.com</email></td><td><email>tseshasayi@abccc.com</email></td><td><email>qwe@rty.ddd</email></td><td><email>qwe@rtty.ggg</email></td>

what i have to do is loop this xml take individual email id and send mail to it,
currently I m using cursor and doing the same.

Is it possible to loop the xml which i m getting instead of cursor as i know cursor hit the performance.

Thanks in Advance for any help.

Regards.

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-07-17 : 07:02:16
A cursor is not bad for performance per se. Doing things one at a time can be bad if you can do it more quickly all at once.

In this case, you have to do things one at at time to do the emailing (I assume), so it doesn't matter greatly how you loop through the items.


Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

rafeequddin_ahmed
Starting Member

23 Posts

Posted - 2008-07-17 : 07:16:26
Ya,but i my case I m sending different content in each mail to each user depending upon his subscription to an item in my project.So if the content is same then we can send to all user with one shoot.
Go to Top of Page
   

- Advertisement -