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 |
desikankannan
Posting Yak Master
152 Posts |
Posted - 2008-04-09 : 08:44:58
|
Hi,i want to trim the query based on the item exampleitemno = '602-54245w-std' i need output like this '54245w'itemno = '602-54w-std' i need output like this '54w' please guideme its very urgent here with iam sending my tried querybut the result is not getting correctly i want to remove the '-' this both left and right '602-54w-std' i need to get 54w onlySELECT 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 |
|
ranganath
Posting Yak Master
209 Posts |
Posted - 2008-04-09 : 10:13:44
|
try with this alsoDEclare @Str Varchar(Max)Set @Str = '6021313-54245w-std131'Select rtrim(Replace(Replace(@Str,right(@str,charIndex('-', Reverse(@Str))),''),Left(@str, charindex('-' , @Str)),'')) |
 |
|
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" |
 |
|
|
|
|
|
|