Solved

SQL Field Mass Update

Posted on 2013-01-07
3
273 Views
Last Modified: 2013-01-16
SELECT     custno, ldate, custstat
FROM         arcust

"ldate" is last date of sale dates formatted like "6/6/2007 12:00:00 AM"  The time is the same for all the dates.

"custstat" date is a "I" or "A".  This field is for active or in-active.

I am looking to make all customer with a last date of sale of 12/31/11 or older have a status of "I"
0
Comment
Question by:jasonspopma
[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
3 Comments
 
LVL 22

Assisted Solution

by:Steve Wales
Steve Wales earned 125 total points
ID: 38752005
Assuming that ldate is a char field, this should do it:

update arcust
set custstat = 'I'
where convert(datetime, ldate, 101) <= convert(datetime, '20111231')
0
 
LVL 22

Expert Comment

by:Steve Wales
ID: 38752035
As long as the time portion of every value in your column is represented as midnight, the above should do the trick.
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 125 total points
ID: 38756184
"ldate" *displays* like that in the SELECT, but since that's the default for a datetime, it's likely (hopefully) a datetime data type.

If so, this is best.  And even if it's varchar this will work (as long as all values are valid datetimes):


UPDATE dbo.arcust
SET custstat = 'I'
WHERE
    ldate < CAST('20120101' AS datetime)
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

710 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