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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-05-23 : 08:07:01
|
| KGarf writes "I am using SQL 2000 and my operating system is Win NT.I have a database field called Reasons that contains one or more reasons. If there is more than one reason the reasons are separated by an underscore character like so:NOEXP_LATEWhat I need to do in a stored procedure is to split this field up into however number of reasons there are. For example:ID 1Reasons LATE_NOADDWould become ID 1Reason1 LATEReason2 NOADDANDID 2Reasons NOEXP_NOADD_LATE_NOGCGWould become ID 2Reason1 NOEXPReason2 NOADDReason3 LATEReason4 NOGCGI'm sure i'd have to do a loop to check the number of occurrences of the underscore character and then split the string from left to right and increment each reason by 1.I only need to split this field into the number of reasons in a stored procedure. I would appreciate your help on this one. Many thanks." |
|
|
nr
SQLTeam MVY
12543 Posts |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-05-23 : 08:51:41
|
| As always, consider the radical idea of normalizing your database as well.http://www.datamodel.org/NormalizationRules.htmlYou should never store multiple values in the same column in a single row. Break it out into a related table.- Jeff |
 |
|
|
|
|
|