| Home | About Us | Sybase Training | Synergy | Consulting | Job Openings | Tech Videos | Rules and Disclaimer | Search |
![]() |
| Home | About Us | Sybase Training | Synergy | Consulting | Job Openings | Tech Videos | Rules and Disclaimer | Search |
|
how to separate a string
|
|
11-10-2011, 11:51 AM
Post: #1
|
|||
|
|||
|
how to separate a string
Hi, Can any one tell me how to separate a string with comma(,) with ',' eg:'a,b,c' to 'a','b','c' Thanks Neelima |
|||
|
11-10-2011, 02:40 PM
Post: #2
|
|||
|
|||
|
RE: how to separate a string
Hi, Try this one if it works Code: create procedure char_separator( BRs, Pradyut |
|||
|
11-11-2011, 05:06 PM
Post: #3
|
|||
|
|||
|
RE: how to separate a string
Sruthi I think you mean: how does one break up a string, which is a concatenated list of comma-separated values, into separate elements. Is that right ? No problem. Easy as pie. But there are constraints on the coding, which must be answered first. 1. Do you always have 3 elements, or is the number of elements variable ? 2. If the no of elements is variable, what is the maximun number ? 3. Do you want a proc or a function ? or just an SQL code segment ? 4. When you call the proc or function, of course @input will contain the single comma-separated string. How would you like the multiple elements produced, to be output ? Do you want @out_1, @out_2, @out_3, @out_99 ? Or would you like a single-column result set containing single elements to be returned ? (11-10-2011 02:40 PM)pradyut.dhara Wrote: Try this one if it works That certainly does what has been asked of it. What do you get with: Code: DECLARE @input VARCHAR(1024), @output VARCHAR(1024)Ashirvad to my Shishyas, Cheers to the others Derek Asirvadem Information Architect / Sr Sybase DBA Website Selection of Useful Documents for the Sybase DBA |
|||
|
11-14-2011, 03:15 PM
Post: #4
|
|||
|
|||
|
RE: how to separate a string
Not sure if this will work ... Try it ... You can program it if you want. select stuff ('a,b,c', 2, 4, "','b','c'" ) Cheers Sukhesh (11-11-2011 05:06 PM)DerekAsirvadem Wrote: Sruthi Ohhh ... just found another function (not sure if this is in new releases) ... select str_replace ('a,b,c',",","','") Worth a try. Cheers Sukhesh (11-14-2011 03:15 PM)sukheshnair Wrote: Not sure if this will work ... Try it ... You can program it if you want. |
|||
|
« Next Oldest · Next Newest »
|