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 |
|
sweet_777
Starting Member
16 Posts |
Posted - 2010-10-21 : 09:21:46
|
| HI all,in my O/P IS LIKE THIS: 1A2B3CHOW TO SPLIT COMMA SEPARATED VALUE EX:1,A,2,B,3,Cif any body knows please let me knowThanks & RegardsSweet_77 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-21 : 09:58:18
|
You are always asking for things that should better not be done in SQL Server.I am curious about what all that trash should be for.Also you are never giving response about given solutions if they work for you or not.Hm... No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Devart
Posting Yak Master
102 Posts |
Posted - 2010-10-21 : 10:02:02
|
| Hello,You can create scalar-valued function and use it.For example:CREATE FUNCTION f_str_separator( @string varchar(8000),@separator varchar(10))RETURNS varchar(8000)ASBEGIN DECLARE @len int DECLARE @i int DECLARE @new varchar(8000) SET @i=1 SET @len = datalength(@string) SET @new = '' WHILE @i<=@len BEGIN SET @new = @new+right(left(@string,@i),1)+@separator SET @i=@i+1 END RETURN @newENDGOSELECT dbo.f_str_separator('1A2B3C',',')ORSELECT dbo.f_str_separator(<string_valued_field>,',')FROM <your_table_name>Best regards,Devart,SQL Server Tools:dbForge Schema ComparedbForge Data ComparedbForge Query Builder |
 |
|
|
|
|
|
|
|