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
 General SQL Server Forums
 New to SQL Server Programming
 left and charindex function

Author  Topic 

krishna_yess
Yak Posting Veteran

81 Posts

Posted - 2008-09-19 : 05:19:32
can i use OR with left and charindex together..

some thing like this



select (left(product,charindex('_',product)))
OR
(left(product,charindex(' ',product)))
AS 'Product'



thanks

NeilG
Aged Yak Warrior

530 Posts

Posted - 2008-09-19 : 05:38:11
repeated request please try and one post one

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=110968

**************************
Check Check and double check it's the safest way
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-19 : 05:39:25
Like this
select 
case when charindex('_',product)>0 then (left(product,charindex('_',product)))
when charindex(' ',product)>0 then (left(product,charindex(' ',product)))
else
product
end
AS 'Product'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -