Home » RDBMS Server » Server Administration » Can we play with strings?
Can we play with strings? [message #372979] Tue, 20 March 2001 16:52 Go to next message
marco
Messages: 46
Registered: March 2001
Member
I'm trying to change strings like this one :

Joe Smith
INTO
SMITH, Joe

Can it be done? Thanks in advance.
Re: Can we play with strings? [message #372987 is a reply to message #372979] Tue, 20 March 2001 22:38 Go to previous messageGo to next message
Thirumalai and Prakash
Messages: 23
Registered: March 2001
Junior Member
Hi Macro,
We can do like this
upper(substr(name,instr(name,' '))) ||', '|| substr(name,1,instr(name,' '))

S.Thirumalai
Another Question [message #372991 is a reply to message #372979] Wed, 21 March 2001 10:32 Go to previous messageGo to next message
marco
Messages: 46
Registered: March 2001
Member
I don't understand what instr i should put to make
it happen. I have a table with thousands of names.
Tell me if this could work

update table_name
set column_name = upper(substr(name, ???(name, '')
etc.
Re: Another Question [message #373005 is a reply to message #372979] Wed, 21 March 2001 23:14 Go to previous messageGo to next message
Thirumalai and Prakash
Messages: 23
Registered: March 2001
Junior Member
Hi Macro,

INSTR is a function can be used to find out location of a "string" within another "string"
Syntax is

INSTR("source string","search string").

You can update table as follows
UPDATE table_name set column_name=upper(substr(column_name,instr(column_name,' '))) ||', '|| substr(column_name,1,instr(column_name,' '));

And also, you can update

update table_name set column_name= upper(substr(
column_name,starting position,end position));

Hope it helps
S.Thirumalai
Thank you [message #373013 is a reply to message #372979] Thu, 22 March 2001 11:32 Go to previous message
marco
Messages: 46
Registered: March 2001
Member
It helped a lot, thank you.

Marco
Previous Topic: Re: To remove blanks within a field
Next Topic: Deleting Tables
Goto Forum:
  


Current Time: Wed May 29 05:22:22 CDT 2024