Rahul Rahul -4 years ago 141
SQL Question

How to apply trim inside a query for a column in a table

I have data in a row for column TEST1 (Table Name: TableTest) like

<n0:RouterName Value="ST_APOP"/>
<n0:ExtZone/>
<n0:SalesOrders>
<n0:SalesOrder ValidationResult="SUCCESS">
<n0:SalesOrderID Value="4F47N006800000_0261"/>


I need to select 4F47N006800000_0261 value in my select query. How to trim that.

Answer Source

try this:

select   
substr(column_name,instr(column_name,'Value',1,2)+7,length(substr(column_name,instr(column_name,'Value',1,2)+7))-3)
 from
test1
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download