Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-09-21
7
Medium Priority
?
298 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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 …

604 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