Solved

How to update part of a sql field

Posted on 2008-10-20
2
632 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Read about achieving the basic levels of HRIS security in the workplace.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

707 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

17 Experts available now in Live!

Get 1:1 Help Now