Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / General DB Topics / General DB Topics / August 2003

Tip: Looking for answers? Try searching our database.

SQL Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Markus Bott - 29 Aug 2003 09:55 GMT
Hi,

i am looking for a solution for the following problem.

i got filenames saved a strings in a database. filenames look like :
'test1.jpg', 'test2.jpg' and so on ....

Some files have been imported wrong, they are named like 'test4 copy.jpg'.

My question is ... is it possible to rename the filenames with a sql
query, so that the 'copy' part will be deleted ?

any help on this problem would be great

Greetings,

Markus
Jarl - 29 Aug 2003 11:17 GMT
> Hi,
>
[quoted text clipped - 8 lines]
> My question is ... is it possible to rename the filenames with a sql
> query, so that the 'copy' part will be deleted ?

Try this:

UPDATE files_table
 SET file = SUBSTRING(file FROM 1 FOR POSITION(' copy' IN file)-1) ||
            SUBSTRING(file FROM POSITION(' copy' IN file) + 5 FOR
              CHARACTER_LENGTH(file) - POSITION(' copy' IN file)-1 + 5)
WHERE
 LOWER(file) LIKE '% copy.%';

/Jarl
Markus Bott - 29 Aug 2003 11:57 GMT
>>Hi,
>>
[quoted text clipped - 19 lines]
>
> /Jarl

i got it solved :

UPDATE table SET name=REPLACE(name, ' copy','')

Thx.

Markus
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.