Link to home
Start Free TrialLog in
Avatar of RosePat
RosePat

asked on

I need help with iterating the records of a database table and populating a field with the concatenation of 2 fields in the table.

I currently have a table with the Following fields and records:

Class_ID, Class_Day, Start_Time, End_Time
"GMS-557-01","T","08:30AM","10:50AM"
"GMS-557-01","TH","08:30AM","10:50AM"
"GMS-595Y-01","T","1:00PM","2:50PM"
"GMS-610-01","M","08:30AM","11:50PM"
"GMS-623-01","M","01:00PM","05:50PM"
"GMS-623-01","W","03:00PM","04:50PM"
"GMS-623-01","F","01:00PM","02:30PM"
"GMS-649-01","W","08:00AM","09:50AM"
"GMS-649-01","F","08:00AM","09:50AM"
"GMS-710-01","TBA","08:00AM","09:50AM"

After running a stored procedure preferably or a vb2005 sub procedure in the code of my asp.net 2.0 project I need to have the day(s) that each class meets concatenated and entered in the Class_Days field.

Class_ID, Class_Day, Start_Time, End_Time, Class_Days
"GMS-557-01","T","08:30AM","10:50AM","T,TH"
"GMS-557-01","TH","08:30AM","10:50AM","T,TH"
"GMS-595Y-01","T","1:00PM","2:50PM","T"
"GMS-610-01","M","08:30AM","11:50PM","M"
"GMS-623-01","M","01:00PM","05:50PM","M,W,F"
"GMS-623-01","W","03:00PM","04:50PM","M,W,F"
"GMS-623-01","F","01:00PM","02:30PM","M,W,F"
"GMS-649-01","W","08:00AM","09:50AM",,"W,F"
"GMS-649-01","F","08:00AM","09:50AM",,"W,F"
"GMS-710-01","TBA","08:00AM","09:50AM","TBA"

Your help is greatly appreciated!
ASKER CERTIFIED SOLUTION
Avatar of EugeneZ
EugeneZ
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RosePat
RosePat

ASKER

Thank you so much EugeneZ, this is great!  You well deserve your rank!
Here is my test and the results I got:
My test:

select * ,dbo.udf_Class_Day('GMS-623-01') as ALL_Days from MyClass
where Class_ID =N'GMS-623-01'

GMS-623-01      M      01:00PM      05:50PM      NULL      M,W,F
GMS-623-01      W      03:00PM      04:50PM      NULL      M,W,F
GMS-623-01      F      01:00PM      02:30PM      NULL      M,W,F
Thanks so much!!!
Avatar of RosePat

ASKER

EugeneZ, this is the 1st time I post a question.  You have no idea how much your answer will help me and my project. Thank you so much EugeneZ. You well deserve your rank!
Here is my test and the results I got:
select * ,dbo.udf_Class_Day('GMS-623-01') as ALL_Days from MyClass
where Class_ID =N'GMS-623-01'

GMS-623-01      M      01:00PM      05:50PM      NULL      M,W,F
GMS-623-01      W      03:00PM      04:50PM      NULL      M,W,F
GMS-623-01      F      01:00PM      02:30PM      NULL      M,W,F
Thanks you so much again!!!
you are very welcome :)