473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Update query question

I am trying to transform data inside one of my tables. However, I only
want to change part of the data in a column because the last part is
basically a UniqueID to a file. Is it possible to only change part of
it?

Here is what the column looks like. I have thousands of these.

D:\oldpath\Content\Data\{File1}
D:\oldpath\Content\Previews\Micro\{File1}.jpg
D:\oldpath\Content\Previews\Mini\{File1}.jpg
D:\oldpath\Content\Data\{File2}
D:\oldpath\Content\Previews\Micro\{File2}.jpg
D:\oldpath\Content\Previews\Mini\{File2}.jpg

I tried commands similar to the one below but nothing happened.

update tableinquestion set columninquestion = 'E:\newpath\Data' where
columninquestion like 'D:\oldpath\Content\Data'

Any help would be appreciated.
Jul 20 '05 #1
1 1024
One method:

CREATE TABLE tableinquestion
(
columninquestion varchar(255) NOT NULL
)

INSERT INTO tableinquestion VALUES('D:\oldpath\Content\Data\{File1}')
INSERT INTO tableinquestion
VALUES('D:\oldpath\Content\Previews\Micro\{File1}. jpg')
INSERT INTO tableinquestion
VALUES('D:\oldpath\Content\Previews\Mini\{File1}.j pg')
INSERT INTO tableinquestion VALUES('D:\oldpath\Content\Data\{File2}')
INSERT INTO tableinquestion
VALUES('D:\oldpath\Content\Previews\Micro\{File2}. jpg')
INSERT INTO tableinquestion
VALUES('D:\oldpath\Content\Previews\Mini\{File2}.j pg')
GO

UPDATE tableinquestion
SET columninquestion = 'E:\newpath\Data' +
REVERSE(
SUBSTRING(
REVERSE(
columninquestion), 1, CHARINDEX('\',
REVERSE(columninquestion))))
FROM tableinquestion
WHERE
columninquestion LIKE 'D:\oldpath\Content\Data%'

--
Hope this helps.

Dan Guzman
SQL Server MVP

"C.P." <ca**********@yahoo.com> wrote in message
news:8b**************************@posting.google.c om...
I am trying to transform data inside one of my tables. However, I only
want to change part of the data in a column because the last part is
basically a UniqueID to a file. Is it possible to only change part of
it?

Here is what the column looks like. I have thousands of these.

D:\oldpath\Content\Data\{File1}
D:\oldpath\Content\Previews\Micro\{File1}.jpg
D:\oldpath\Content\Previews\Mini\{File1}.jpg
D:\oldpath\Content\Data\{File2}
D:\oldpath\Content\Previews\Micro\{File2}.jpg
D:\oldpath\Content\Previews\Mini\{File2}.jpg

I tried commands similar to the one below but nothing happened.

update tableinquestion set columninquestion = 'E:\newpath\Data' where
columninquestion like 'D:\oldpath\Content\Data'

Any help would be appreciated.

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Surendra | last post by:
I have this query that I need to use in an Update statement to populate a field in the table by the value of Sq ---------------------------------------------------------------------------- Inline...
2
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An...
4
by: deko | last post by:
I'm trying to update the address record of an existing record in my mdb with values from another existing record in the same table. In pseudo code it might look like this: UPDATE tblAddress SET...
12
by: si_owen | last post by:
Hi all, I have a SQL query that worked fine in my project until it came to testing. I found that the NvarChar fields I have wont accept the use of an ' My code and query is here does anyone...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.