Solved

Script to change value in mssql

Posted on 2010-11-23
2
239 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

912 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now