Comma Delimited Row
Posted on 2012-03-20
OK this may NOT be the best way to do this, so I need some advice on this one!
I have a column in my database called Departments and I'm storing the departments that are affected by an an incident. I'm ONLY storing the department ID comma demlimited so for example...
However when running reports I need to first get the Incident by date range and then pull all the incidents in that date range get the departments affected and replace the Department ID from the string and replace it with the name of the department.
1 1,2 would be come...
Then I need to get the Department Name...
and then put it back togehter
for the final output.
Hope this makes sense...but if there is a better way please let me know!
The reason I selected this method for storing all the affected departments in one field seperated by commas was to save space and or having another table. Seemed like a good idea at the time.
In short I need to take a comma demlimited field get the names and turn it back into a comma demilited field for each record returned in the date range.