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)
 query problem ?

Author  Topic 

spock
Starting Member

35 Posts

Posted - 2002-02-15 : 23:35:11
Hi

i have an employee table like

table employee(
emp_id int,
orgn_id int,
mgr_id int,
e_mail varchar(60),
emp_frst_name varchar(60),
emp_last_name varchar(60)
)

i need to send an email to all the managers about the employees under them. the client says there are instances of a manager having aroung 110 employees reporting to him . i thought i could build a string of all the names comma separated in a column (using all the prev posts and articles in sqlteam abt building csv i was able to do that and get it working ) and return it to my vb program which would then mail the names to the respective manager. but then it struck me that 110 * 120 (total names * the size of the name field) would cross the row limit of 8000 bytes. so i am thinking that the only solution would be to run the query

select emp_frst_nme,emp_lst_nme from employee where mgr_id = 2134
and then append the names to the email by reading each of these names into the mail body from the recordset .

so what would your suggestion be guys ?

thanks
kaushik

joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2002-02-18 : 21:37:40
One option would be to open a recordset and then create an array and use array_variable = rs.getrows. Then you can immediately close the connection to the database and loop through the array values setting the mail message as follows:

For iRowLoop = 0 to UBound(array_variable,2)

message_variable = message_variable & aTable1Values(1,iRowLoop) & ", "

Next

This would keep database connection to a minimum and allow the programming to be done on the client side. This is especially beneficial when programming web pages.

Let me know if this helps.

Go to Top of Page

spock
Starting Member

35 Posts

Posted - 2002-02-18 : 22:03:31
joldham,

quote:

Let me know if this helps.



it was definetely helpful. was able to get that working.

thanks
kaushik



Go to Top of Page
   

- Advertisement -