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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 case

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-11-16 : 05:51:32
Does the case statement look ok to you? It seems only the first when clause inside the case works and not the second one. Notice they are both doing the > 1

select
Bid_Size =
case
when len(Bid_Size) > 1 then replace(Bid_Size, 'A', '')
when len(Bid_Size) > 1 then replace(Bid_Size, 'E', '')
end,
Ask_Price
from
tblData

hitman
Starting Member

23 Posts

Posted - 2007-11-16 : 06:04:25
well, you can nest 2 replaces

replace(replace(Bid_Size, 'A', ''), 'E', '')

-----------------------
http://www.sqltips.info
-----------------------
Go to Top of Page

georgev
Posting Yak Master

122 Posts

Posted - 2007-11-16 : 07:42:59
What do you want to do when Len(Bid_Size) <= 1?
[CODE]
SELECT CASE WHEN Len(Bid_Size) > 1 THEN
Replace(Replace(Bid_Size, 'A', ''), 'E', '')
ELSE
'else value'
END As [Bid_Size]
, Ask_Price
FROM tblData
[/CODE]
What are you actually trying to achieve here?


George
<3Engaged!
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-11-16 : 08:04:44
Solved. thanks
Go to Top of Page
   

- Advertisement -