Solved

How to update part of a sql field

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Read about achieving the basic levels of HRIS security in the workplace.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

867 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

16 Experts available now in Live!

Get 1:1 Help Now