Solved

How to update part of a sql field

Posted on 2008-10-20
2
634 Views
Last Modified: 2012-06-22
Say I have the following rows in my DB table

19.28      Windows200364      \\machine1\Drivers\aaa\      3/5/2007 2:04:27 PM      storage      930
19.28      Windows200332      \\machine1\Drivers\aaa\      3/5/2007 2:04:25 PM      storage      775

All I want to do is change the machine1 in the third column to machine2 so i end up with

19.28      Windows200364      \\machine2\Drivers\aaa\      3/5/2007 2:04:27 PM      storage      930
19.28      Windows200332      \\machine2\Drivers\aaa\      3/5/2007 2:04:25 PM      storage      775

Basically just a partial search and replace.
I have NO idea how to go about this.
0
Comment
Question by:Matt_Du
2 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 65 total points
ID: 22763783
UPDATE SomeTable
SET MachineName = REPLACE(MachineName, '\\machine1\', '\\machine2\')
WHERE MachoneName LIKE ''\\machine1\%'
0
 
LVL 6

Assisted Solution

by:llman
llman earned 60 total points
ID: 22763840
UPDATE DbTable SET Col3 = REPLACE(Col3, 'machine1', 'machine2')

replace DbTable and Col3 with your table name and column name
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

Suggested Solutions

Title # Comments Views Activity
sqlserver get datetime field and create a string 5 18
horizontal scale out 29 18
awk and Pythagoras? 5 10
average of calculation (TSQL) 4 11
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Viewers will learn how the fundamental information of how to create a table.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

825 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