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 |
|
andryi
Starting Member
17 Posts |
Posted - 2009-10-07 : 11:09:02
|
| How can divide one string in many substrings, I meanIf I have a string like this : 'abc,def,hij,'how can obtain this: abc def hij |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-10-07 : 11:14:12
|
HiTry this....DECLARE @SPLIT_DATA VARCHAR(100)--size is upto uSET @SPLIT_DATA = 'abc,def,hij'SELECT @SPLIT_DATA= 'SELECT '''+REPLACE(@SPLIT_DATA,',',''' UNION ALL SELECT ''')+''''EXEC(@SPLIT_DATA) -------------------------R... |
 |
|
|
andryi
Starting Member
17 Posts |
Posted - 2009-10-07 : 11:22:34
|
| OMG!!, is perfect!!!! very thank you rajdaksha |
 |
|
|
andryi
Starting Member
17 Posts |
Posted - 2009-10-07 : 11:47:17
|
| but and If I want to that each substring be each variable, like this:declare @string1 varchar(50),@string2 varchar(50), @string3 varchar(50)set @string1 = 'abc',set @string2 = 'def',set @string3 = 'hij' |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-08 : 04:31:44
|
quote: Originally posted by andryi but and If I want to that each substring be each variable, like this:declare @string1 varchar(50),@string2 varchar(50), @string3 varchar(50)set @string1 = 'abc',set @string2 = 'def',set @string3 = 'hij'
What is the maximum number of possible values you would have?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|