Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL update query Help

Status
Not open for further replies.

Kruzer

Programmer
Jun 16, 2000
117
US
I need to update some records by removing prefixes from a value in several hundred records.

current value is "UUU\joeuser"

need the value to be "joeuser"

How would I write the SQL query to update multiple records in the database so that the prefix is removed?


UPDATE Table
SET dUser = '%\%'
WHERE column_name = some_value



Dano
What's your major malfunction
 

Dano,

I would use a REPLACE. Something like this:

REPLACE MyField WITH SUBSTR(MyField,5) ;
FOR LEFT(MyField,4) = "UUU/"

You can of course modify this to take account of different prefixes, or to make it more general.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Dano,

Perhaps the following construct would help?

RIGHT(cField,LEN(cField)-AT('\',cField))

Regards,
Jim
 
Dano,

If the "prefix" in your data always ends in "\", you can simply use JUSTSTEM() in a REPLACE statement.

Teresa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top