Solved

Urgent --Multiple updates with one Query on the same column - either SP or Query

Posted on 2004-09-21
7
273 Views
Last Modified: 2006-11-17
i have a column that is auto populated daily of type varchar.  I would like a stored procedure that I could execute nightly that would go through the table and update it accordingly.

The table consists of values like "1 year", "2 years", ect.  I want to strip the year(s) off of the table as well as look for some other things.

Is this possible to do in a simple query or stored procedure?
0
Comment
Question by:Jbryant22
  • 3
  • 3
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 12113114
you can use something like this

UPDATE TableNAme SET TableName.Duration = Replace(Replace([Duration],"years",""),"year","")
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12113148
What sort of other things do you want to look for?
0
 

Author Comment

by:Jbryant22
ID: 12113161
the table contains auto, none, and other values considered invalid so I want to set those to 0.  So the query above will just leave me with the number?
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12113183
Hmm - something like this, I think:

UPDATE MyTable SET MyField=Str$(Val([MyField]))

should do it. This will update the field to the number if it starts with a number - otherwise, it updates it to 0.
0
 

Author Comment

by:Jbryant22
ID: 12113205
oops, I forgot one thing.  the column also contains either Auto or other.  I have to treat these differently and I have to leave those alone.  I deal with them in the asp code.  so i could do a where myfield <> "other" or myfield <>"auto".  right?
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 500 total points
ID: 12113220
Something like this in that case:

UPDATE MyTable SET MyField=IIf([MyField]='Auto' Or [MyField]='Other',[MyField],Str$(Val([MyField])))

I *think* that will work from asp.
0
 

Author Comment

by:Jbryant22
ID: 12113233
cool thanks for the help
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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