By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,574 Members | 1,977 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,574 IT Pros & Developers. It's quick & easy.

Is there a way to split the contents of a string?

P: 7
I have a string of the form '_10_245_' of varchar type to represent a list of integers.

Is there a way to extract the numbers out of that string?

examples of the string:

'_34_'

'_123_78_'

'_34_155_134_'

I manged to convert the string into the form of '34 155 134' using replace , ltrim and rtrim...but what should I do next?How can I split that string? As soon as I do that, I will convert each substring into int using the cast function.

Also note that the string it's not always the same; there's a column in a table containing those strings as its values.

Each of those numbers is a code and exists in another table A in an int column. Table A also provides each code's description in a varchar column.

I want to match each number in my string to its description in table A.

Any suggestions?

Thanks in advance
Nov 18 '08 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
You have a "_" delimited string.

Option 1:

Parse it with a lot of substring or loop.

Option 2:
Use this technique.

-- CK
Nov 18 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.