Solved

Script to change value in mssql

Posted on 2010-11-23
2
255 Views
Last Modified: 2012-05-10
Hi.
I Want to change a part of a value in one of my table.
The table consist of lots of paths to documents, and when i now change the path i need to change all of the values.
ie:

C:\documents\F0001\document1.txt
C:\documents\F0001\document2.txt
to
d:\new\F9999\document1.txt
d:\new\F9999\document2.txt

I want to change the C:\documents\F0001 part to d:\new\F9999.

any suggestions?
0
Comment
Question by:valeoit
2 Comments
 
LVL 19

Accepted Solution

by:
Bhavesh Shah earned 500 total points
ID: 34196825
Hi,

If thats is hardcode you can do

UPDATE TABLE
SET file = REPLACE(FILE,'C:\documents\F0001','D:\new\F9999')
WHERE FILE LIKE 'C:\documents\F0001%'
0
 

Author Comment

by:valeoit
ID: 34196882
Thanks for quick answer.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question