UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Update Multiple Records In A Field    
 
   
rwetzler
post Mar 4 2012, 11:25 AM
Post #1

UtterAccess Member
Posts: 21



I am trying to get my data consistant in an access file containing my banking information. I download the transactions in *.csv format and then import them into access. The field data naming conventions varies sometimes so I want to update the field data to be consistant. The problem is I don't want to have to create 50 different queries to accomplish this. I found some info on the net as below where I can accomplish this with one query but can't seem to figure it out. I could then run this one query every few months or so and bingo my data would look nice and neat!
Trying to use SQL and am a newbie..

UPDATE Checking
SET Payee = Date
WHEN LIKE '*CAPITAL*' THEN 'CAPITAL ONE'
WHEN LIKE '*WAL*' THEN 'WAL-MART'
WHEN LIKE '*PEN*' THEN 'JC PENNEY'
WHEN LIKE' *KOH*' THEN 'KOHLS'
When Like' *so*' THEN 'SO ON AND SO FORTH'
END
WHERE Checking.Date >#1/1/2012#
Go to the top of the page
 
+
theDBguy
post Mar 4 2012, 11:30 AM
Post #2

Access Wiki and Forums Moderator
Posts: 48,600
From: SoCal, USA



Hi,

What version of Access are you using? Knowing the Access version may help us determine a more appropriate response to your question.

That doesn't look like Access SQL (at least I am not familiar with it). Where did you get it? Is it maybe a T-SQL syntax?

Perhaps you'd be able to get the same thing using the Replace() function.

Just my 2 cents... (IMG:style_emoticons/default/2cents.gif)
Go to the top of the page
 
+
rwetzler
post Mar 4 2012, 11:34 AM
Post #3

UtterAccess Member
Posts: 21



Version is 2003
the "Replace" will work for me I'm just trying to come up with some way to accomplish this.

Here is the link which got me started on this: http://www.karlrixon.co.UK/writing/update-...ngle-sql-query/
Go to the top of the page
 
+
arnelgp
post Mar 4 2012, 11:38 AM
Post #4

UtterAccess Ruler
Posts: 1,090



...SQL

This post has been edited by arnelgp: Mar 4 2012, 11:42 AM
Go to the top of the page
 
+
theDBguy
post Mar 4 2012, 12:54 PM
Post #5

Access Wiki and Forums Moderator
Posts: 48,600
From: SoCal, USA



QUOTE (arnelgp @ Mar 4 2012, 09:38 AM) *
...SQL

Thanks, Arnel. I did find a similar example in T-SQL at MSDN.

CODE
USE AdventureWorks2008R2;
GO
CREATE PROCEDURE HumanResources.Update_VacationHours
@NewHours smallint
AS
SET NOCOUNT ON;
UPDATE HumanResources.Employee
SET VacationHours =
    ( CASE
         WHEN SalariedFlag = 0 THEN VacationHours + @NewHours
         ELSE @NewHours
       END
    )
WHERE CurrentFlag = 1;
GO

EXEC HumanResources.Update_VacationHours 40;
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 08:28 AM