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 2000 Forums
 Transact-SQL (2000)
 query trim

Author  Topic 

desikankannan
Posting Yak Master

152 Posts

Posted - 2008-04-09 : 08:44:58
Hi,
i want to trim the query based on the item example
itemno = '602-54245w-std' i need output like this '54245w'
itemno = '602-54w-std' i need output like this '54w' please guide
me its very urgent here with iam sending my tried query
but the result is not getting correctly
i want to remove the '-' this both left and right '602-54w-std' i need to get 54w only
SELECT mtl.SEGMENT1 FROM apps.mtl_system_items_b mtl WHERE ( trim(SUBSTR(mtl.SEGMENT1,INSTR(mtl.SEGMENT1,'-')+1,INSTR(mtl.SEGMENT1,'-')+ 2))) = '9616V/4' AND mtl.ORGANIZATION_ID = '104' and mtl.segment1 like '6%'

Desikankannan

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-09 : 08:48:44
Dupe
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=100580



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

ranganath
Posting Yak Master

209 Posts

Posted - 2008-04-09 : 10:13:44
try with this also

DEclare @Str Varchar(Max)
Set @Str = '6021313-54245w-std131'
Select rtrim(Replace(Replace(@Str,right(@str,charIndex('-', Reverse(@Str))),''),Left(@str, charindex('-' , @Str)),''))
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-09 : 10:15:38
SELECT PARSENAME(REPLACE(ItemCode, '-', '.'), 2)
FROM Table1


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -