473,387 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help with UPDATE

I have a column in one of my tables that needs to have about half of its
values updated.

The data looks like this:

A\B0andSomeVaryingStuff.mp3

I'd like to update it to:

A\C-B0andSomeVaryingStuff.mp3

The A, \-sign, B, C, .mp3 and - are literals. The
"andSomeVaryingStuff" changes. All I want to do is to replace the \B
with \C-B.

So I need to say "Find the instances where there is an A\B0 and replace
the A\B0 with A\C-B0 leaving the andSomeVaryingStuff.mp3 the same."

Note that every row will not need to be updated -- only the ones where
the column data begins A\B0.

Can you help?

Thank you,

-- Rick
Jul 20 '05 #1
4 3010
You could use the REPLACE function.

As a safeguard make a new column on your table and run this statement....

UPDATE mpTable SET myNewColumn = REPLACE(myOriginalColumn, 'A\BO', 'A\C-B0')

If it works good, you may be able to then use "SET myOriginalColumn" and
remove the new column. May need tweaked, but see what happens?

:)

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
"Guinness Mann" <GM***@dublin.com> wrote in message
news:MP************************@news.newsguy.com.. .
I have a column in one of my tables that needs to have about half of its
values updated.

The data looks like this:

A\B0andSomeVaryingStuff.mp3

I'd like to update it to:

A\C-B0andSomeVaryingStuff.mp3

The A, \-sign, B, C, .mp3 and - are literals. The
"andSomeVaryingStuff" changes. All I want to do is to replace the \B
with \C-B.

So I need to say "Find the instances where there is an A\B0 and replace
the A\B0 with A\C-B0 leaving the andSomeVaryingStuff.mp3 the same."

Note that every row will not need to be updated -- only the ones where
the column data begins A\B0.

Can you help?

Thank you,

-- Rick

Jul 20 '05 #2
In article <ug**********************@newssvr30.news.prodigy.c om>,
je***@antech.biz.nospam says...
You could use the REPLACE function.

UPDATE mpTable SET myNewColumn = REPLACE(myOriginalColumn, 'A\BO', 'A\C-B0')


I like it. I'm a little confused, though. Don't I need a WHERE clause?

-- Rick
Jul 20 '05 #3
No where clause is required unless you want to selectively update certain
data based on column values.

You could do this if you want...

UPDATE mpTable SET myNewColumn = REPLACE(myOriginalColumn, 'A\BO', 'A\C-B0')
Where myOriginalColumn LIKE '%A\BO%'

But if you are making a new column for the modified (replaced) value it will
not show up since the where clause restricts it to only the rows that need
updated. If you are not making a new column, then the where clause would be
great. Another thing... if you want this to run periodically you can setup
a Sql Agent Job to execute this statement as T-SQL and give it a schedule,
or even run when the server is at idle. Of course, the best practice would
be to eliminate the data entry problem when it's entered. But anyway....

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
"Jerry Boone" <je***@antech.biz.nospam> wrote in message
news:ug**********************@newssvr30.news.prodi gy.com...
You could use the REPLACE function.

As a safeguard make a new column on your table and run this statement....

UPDATE mpTable SET myNewColumn = REPLACE(myOriginalColumn, 'A\BO', 'A\C-B0')
If it works good, you may be able to then use "SET myOriginalColumn" and
remove the new column. May need tweaked, but see what happens?

:)

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
"Guinness Mann" <GM***@dublin.com> wrote in message
news:MP************************@news.newsguy.com.. .
I have a column in one of my tables that needs to have about half of its
values updated.

The data looks like this:

A\B0andSomeVaryingStuff.mp3

I'd like to update it to:

A\C-B0andSomeVaryingStuff.mp3

The A, \-sign, B, C, .mp3 and - are literals. The
"andSomeVaryingStuff" changes. All I want to do is to replace the \B
with \C-B.

So I need to say "Find the instances where there is an A\B0 and replace
the A\B0 with A\C-B0 leaving the andSomeVaryingStuff.mp3 the same."

Note that every row will not need to be updated -- only the ones where
the column data begins A\B0.

Can you help?

Thank you,

-- Rick


Jul 20 '05 #4
In article <Ht*********************@newssvr11.news.prodigy.co m>,
je***@antech.biz.nospam says...
You could do this if you want...

UPDATE mpTable SET myNewColumn = REPLACE(myOriginalColumn,
'A\BO', 'A\C-B0') Where myOriginalColumn LIKE '%A\BO%'
Thanks, Jerry. It worked great as originally posted. After I posted
the query about WHERE (yuk, yuk) I tried it on a restricted range and it
worked so I updated the data in place. (I have a backup.)

...the best practice would be to eliminate the data entry
problem when it's entered.


Roger that. I found the data entry problem halfway through the entry
process and fixed it then. This is a one-time update to fix the entries
done before I fixed the process.

Thanks again!

-- Rick
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Randy Harris | last post by:
I imported records into a table, later found out that many of them had trailing spaces in one of the fields. If I'd caught it sooner, I could have trimmed the spaces before the import. This...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
1
by: Sajid | last post by:
Hello! Experts, I have the following piece of code in VB.NET that I want to use to update any records in the database. I would like to use a code as well as DataGrid to update the records....
1
by: cindy | last post by:
this is the call private void Page_Load(object sender, System.EventArgs e) { OdbcConnection connection = new OdbcConnection ("DSN=PFW52"); CreateDataAdapter(connection); } this is the code,...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
2
by: Hexman | last post by:
Hello All, Well I'm stumped once more. Need some help. Writing a simple select and update program using VB.Net 2005 and an Access DB. I'm using parameters in my update statement and when trying...
6
by: Takeadoe | last post by:
Dear NG, Can someone assist me with writing the little code that is needed to run an update table query each time the database is opened? From what I've been able to glean from this group, the...
1
by: corsibu | last post by:
hello , i just wanted to ask if there's anyone who could help me do the following thing : i have an empty temporary table, this table will have a row filled with data grabbed by a querry at this...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
4
by: charmeda103 | last post by:
i have this program that i am almost done with, i am one part away from being done. the last part is putting the results together; here is the results that i need to put in code. do u have any...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.