Click here to Skip to main content
15,887,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am running through a problem, i am running a query and it returns multiple rows as i wanted, perfect. I had to send message to concern mobile no so i wrote procedure for it that's working but problem is that i am not able to send message to different mobile no i.e. no.s returned by different rows. In short i mean that i want to send messages to all numbers that are returned by query.

SQL
Select CL.[Subject],  D.Name as Designation,  D.MobileNo, CL.LetterNo,'Please Reply To Our Letter No : ' + convert(varchar(50),CL.LetterNo) as SMSMessage
  from CPOCMS.dbo.ComposedLetter CL 
  Join CPOCMS.dbo.Designations D on  CL.Designation_ID = D.DesignationID

 where   convert(date,CL.DeadLineDate) = Convert(date,DATEADD(DAY,1,GETDATE()))

 Exec dbo.ADD_SMS_InQueue 'Requires number', 'requires message'
Posted
Updated 26-May-14 20:56pm
v2

You could use a cursor and loop through all the rows. But why dont you do a bulk insert instead of calling the ADD_SMS_INQueue in a loop?
 
Share this answer
 
Comments
Hunain Hafeez 27-May-14 3:50am    
Bulk insert ? sorry ?
CHill60 27-May-14 4:38am    
If it is any consolation, I haven't a clue what they mean either! You already have the data on a table so I don't see the relevance of bulk insert
As suggested by soumyajayaraj you could use a CURSOR - here's a CP Tip if you haven't used one before How to use Cursor in Sql[^]

Warning - cursors can get very slow with large quantities of data.

I was going to suggest using a function instead of an SP as you could have incorporated that into your query, but AFAIK you cannot send an email from a function, and the little research I've done did not offer an alternative (I only mention it for possible future use)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900