Solved

How to update part of a sql field

Posted on 2008-10-20
2
637 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

687 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