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 |
|
hs123456
Starting Member
6 Posts |
Posted - 2010-03-05 : 09:36:46
|
| I have a field with values separated by two spaces like in @stringdeclare @string varchar(max)SET @string = 'ABC Company XYZ Company DEF Company' SELECT CASE WHEN @string IS NULL THEN 'N/A' ELSE REPLACE(@string, '<br>',' ') END AS CompanyThis does not work. The end result I want is below and it should be part of select statement:ABC CompanyXYZ CompanyDEF Company |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-03-05 : 09:46:25
|
just make a little change:replace(@string,'old_value','new_value) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-05 : 10:09:41
|
| You need a SPLIT function. Search for it hereMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-05 : 10:29:14
|
| will there be always only maximum of 3 or 4 values to split?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-05 : 10:36:09
|
quote: Originally posted by visakh16 will there be always only maximum of 3 or 4 values to split?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
In that case you can use parsename functionMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-05 : 11:23:46
|
quote: Originally posted by madhivanan
quote: Originally posted by visakh16 will there be always only maximum of 3 or 4 values to split?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
In that case you can use parsename functionMadhivananFailing to plan is Planning to fail
exactly that was my point------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|