PC Review


Reply
Thread Tools Rate Thread

Create scripts from Excel

 
 
Sam Commar
Guest
Posts: n/a
 
      16th Aug 2008
I have an excel table which has old and new values for Vendors

So my excel file looks like this- It actually has about 5000+ values:

Old Vendor ID New Vendor ID
ADPINC00 ADPEAS00'
THC TYCHEA
UNHOSE UNIHOS
USS UNISTA


I have to run SQL scripts on a database which will update the value of the
Old Vendor ID with the new Vendor ID
on 5 tables and delete the old vendor ID from one table =Actual e.g below:

update apdoc set vendid = 'ADPINC00' where vendid = 'ADPEAS00';
update aptran set vendid = 'ADPINC00' where vendid = 'ADPEAS00';
update aphist set vendid = 'ADPINC00' where vendid = 'ADPEAS00';
update apadjust set vendid = 'ADPINC00' where vendid = 'ADPEAS00';
update gltran set Id = 'ADPINC00' where Id = 'ADPEAS00' and module = 'GL';
delete from aphist where vendid = 'ADPEAS00'


I would be really grateful if someone could suggest a mechanism to easily
create the scripts as above for the Vendor IDs in my Excel file.

Thank you

S Commar

 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      17th Aug 2008
It would help if you did a manual query of the database in excel while
recording a macro. This would give the basic templet for making the SQL
changes you need.

do the following from Excel worksheet menu
1) Tools - Macro - Record Macro
2) Data - Import External Data - New Database Query
3) Fetch data from the tables you need to modify
4) tools Macro - Stop Recording
5) Alt-F11 (get to VBA window) and get macro from Module Window. Then
modify the code yourself or post the code for others to modify.

"Sam Commar" wrote:

> I have an excel table which has old and new values for Vendors
>
> So my excel file looks like this- It actually has about 5000+ values:
>
> Old Vendor ID New Vendor ID
> ADPINC00 ADPEAS00'
> THC TYCHEA
> UNHOSE UNIHOS
> USS UNISTA
>
>
> I have to run SQL scripts on a database which will update the value of the
> Old Vendor ID with the new Vendor ID
> on 5 tables and delete the old vendor ID from one table =Actual e.g below:
>
> update apdoc set vendid = 'ADPINC00' where vendid = 'ADPEAS00';
> update aptran set vendid = 'ADPINC00' where vendid = 'ADPEAS00';
> update aphist set vendid = 'ADPINC00' where vendid = 'ADPEAS00';
> update apadjust set vendid = 'ADPINC00' where vendid = 'ADPEAS00';
> update gltran set Id = 'ADPINC00' where Id = 'ADPEAS00' and module = 'GL';
> delete from aphist where vendid = 'ADPEAS00'
>
>
> I would be really grateful if someone could suggest a mechanism to easily
> create the scripts as above for the Vendor IDs in my Excel file.
>
> Thank you
>
> S Commar
>
>

 
Reply With Quote
 
Tim Williams
Guest
Posts: n/a
 
      17th Aug 2008
Just create formulas on the sheet which give you the SQL
Eg.

="update apdoc set vendid = '" & A2 & "' where vendid = '" & B2 & "';"

Fill down and copy-paste into a SQL command window.

Tim


"Sam Commar" <(E-Mail Removed)> wrote in message
news:4B9B954B-BAA8-4541-A11B-(E-Mail Removed)...
>I have an excel table which has old and new values for Vendors
>
> So my excel file looks like this- It actually has about 5000+ values:
>
> Old Vendor ID New Vendor ID
> ADPINC00 ADPEAS00'
> THC TYCHEA
> UNHOSE UNIHOS
> USS UNISTA
>
>
> I have to run SQL scripts on a database which will update the value of
> the Old Vendor ID with the new Vendor ID
> on 5 tables and delete the old vendor ID from one table =Actual e.g
> below:
>
> update apdoc set vendid = 'ADPINC00' where vendid = 'ADPEAS00';
> update aptran set vendid = 'ADPINC00' where vendid = 'ADPEAS00';
> update aphist set vendid = 'ADPINC00' where vendid = 'ADPEAS00';
> update apadjust set vendid = 'ADPINC00' where vendid = 'ADPEAS00';
> update gltran set Id = 'ADPINC00' where Id = 'ADPEAS00' and module = 'GL';
> delete from aphist where vendid = 'ADPEAS00'
>
>
> I would be really grateful if someone could suggest a mechanism to easily
> create the scripts as above for the Vendor IDs in my Excel file.
>
> Thank you
>
> S Commar



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: For a website, are Excel scripts better than other programming language scripts? Tim Williams Microsoft Excel Programming 10 31st May 2009 05:11 AM
MSI for create database and execute scripts Alhambra Eidos Kiquenet Microsoft C# .NET 1 15th Sep 2008 08:16 AM
create table scripts shank Microsoft Access Database Table Design 2 23rd Jan 2006 05:35 PM
How do i create automated scripts? =?Utf-8?B?Z29vc2UyMjA=?= Microsoft Access 5 22nd Aug 2005 10:28 PM
Using CMAK to create VPN scripts are no good. Joe M Microsoft Windows 2000 Networking 1 16th Dec 2003 06:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:40 AM.