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
 SQL Server Development (2000)
 how can I extract a substring from an entry?

Author  Topic 

jrumol
Starting Member

2 Posts

Posted - 2005-01-10 : 09:50:31
Hello everybody,

I have a table named ARCHIVO where I save the information of each file I put into a data source. In this table there is a registry named FILENAME where I put the file name =) however, the file name is like that:

P2Ux yz ttt Name

Where:
x=unit
y=phase
z=speciality
ttt=doctype
Name=name

and now I want to extract "x" and save it into the registry UNIT, "y" and save it into the registry PHASE and so on.

I think it should be something like that:

x=SELECT $EXTRACT(FILENAME,4) FROM ARCHIVO 


Can someone help me with that... my knowledge about sql is quite reduced.

Thanks

JRRM


----------------
Learning to fly

MichaelP
Jedi Yak

2489 Posts

Posted - 2005-01-10 : 10:34:59
Lookup SUBSTRING() or PARSENAME() in Books Online.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

jrumol
Starting Member

2 Posts

Posted - 2005-01-11 : 04:12:15
I have tried to do it but it didn't work out.

I am using ORACLE 9i and it doesn't recognize neither the function SUBSTRING not PARSENAME.

Let's say I want the first and the second letter of a department name. I tried that

SELECT SUBSTRING(O_DEPARTNAME,1,2) FROM DEPARTMENT


and it says that can't recognize the SUBSTRING FUNCTION. The same applies to PARSENAME.

Could you help me please =)

JRRM

PS: I searched the forum =) but couldn't find a solution to that.

----------------
Learning to fly
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2005-01-11 : 05:41:42
This is a SQLServer site....you may be best served by asking on www.dbforums.com
Go to Top of Page

sreemace
Starting Member

9 Posts

Posted - 2005-01-11 : 06:06:55
Try this:
SELECT SUBSTR(O_DEPARTNAME, 1, 2) FROM DEPARTMENT;

Other String function: 'INSRT'

Go thru below link:

http://www.psoug.org/reference/substr_instr.html

Sree

Thanks & Regards,
Sreejith G
Go to Top of Page
   

- Advertisement -