Solved

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

Posted on 2004-09-21
7
285 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

726 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