473,378 Members | 1,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Delete Columns with 0 value

I have been given a database with 2,944 tables in it. Each table has
35 rows and columns labeled Dur, 20, 21, 22, 23, 24, 25, 26 ..... 64,
65. They contain insurance rates by age and band.

Currently all the tables are the same length and width. I need to go
through all 2,944 and delete out any colmn with a zero value. For
some that might be columns 64 and 65, for some 50 through 65, or any
other possible combination.

If I have to open 2,944 tables individually, I'll cry. Is there a way
to cycle through the tables and look for columns with a 0 value and
delete them with VB?

Thanks in advance,
Laura
Jun 27 '08 #1
3 1653
On Sat, 10 May 2008 08:28:51 -0700 (PDT), musicloverlch
<lh****@gmail.comwrote:

That's a HORRIBLE database design, but that aside. Off the cuff you
can do something like this:
public sub FixIt()
dim db as dao.database
dim td as dao.tabledef
dim fld as dao.field
set db=currentdb
for each td in db.tabledefs
for each fld in td.fields
DeleteIfNeeded td, fld
next fld
next td
end sub

private sub DeleteIfNeeded(td as tabledef, fld as field)
if dcount(fld.name, td.name, fld.name & "<>0") 0 then
td.fields.delete fld.name
end if
end sub
>I have been given a database with 2,944 tables in it. Each table has
35 rows and columns labeled Dur, 20, 21, 22, 23, 24, 25, 26 ..... 64,
65. They contain insurance rates by age and band.

Currently all the tables are the same length and width. I need to go
through all 2,944 and delete out any colmn with a zero value. For
some that might be columns 64 and 65, for some 50 through 65, or any
other possible combination.

If I have to open 2,944 tables individually, I'll cry. Is there a way
to cycle through the tables and look for columns with a 0 value and
delete them with VB?

Thanks in advance,
Laura
Jun 27 '08 #2
rkc
musicloverlch wrote:
I have been given a database with 2,944 tables in it. Each table has
35 rows and columns labeled Dur, 20, 21, 22, 23, 24, 25, 26 ..... 64,
65. They contain insurance rates by age and band.

Currently all the tables are the same length and width. I need to go
through all 2,944 and delete out any colmn with a zero value. For
some that might be columns 64 and 65, for some 50 through 65, or any
other possible combination.

If I have to open 2,944 tables individually, I'll cry. Is there a way
to cycle through the tables and look for columns with a 0 value and
delete them with VB?
You should cry anyway because what you have been given is not a
database, it's a big pile of dung. Your current task is apparently
to pile it higher.

From the tiny bit of information in your post and what little I know
about the insurance business I would say you should be looking at a
single table with 4 columns to hold the whole pile.

InsuranceRates(Age, Rate, PercentAbove, PercentBelow)

Getting the information from your 2944 tables with 35 rows and a
ridiculous number of columns into that one table could in fact be scripted.

That would make your life much easier and probably triple your currently
available thumb twiddling time.

The answer to your original question is yes, but I wouldn't want to show
you how because it's a waste of time.



Jun 27 '08 #3
On Sat, 10 May 2008 12:40:10 -0400, rkc <rk*@rkcny.yabba.dabba.do.com>
wrote:

I fully agree, but figured that if they got to 2944 without realizing
this, we might have to chalk them up in the Lost Cause column.

-Tom.

<clip>
>
You should cry anyway because what you have been given is not a
database, it's a big pile of dung. Your current task is apparently
to pile it higher.

From the tiny bit of information in your post and what little I know
about the insurance business I would say you should be looking at a
single table with 4 columns to hold the whole pile.

InsuranceRates(Age, Rate, PercentAbove, PercentBelow)

Getting the information from your 2944 tables with 35 rows and a
ridiculous number of columns into that one table could in fact be scripted.

That would make your life much easier and probably triple your currently
available thumb twiddling time.

The answer to your original question is yes, but I wouldn't want to show
you how because it's a waste of time.

Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: php newbie | last post by:
I am getting error messages when I try to delete from a table using the values in the table itself. The intent is to delete all rows from TableA where col_2 matches any of the col_1 values. ...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
8
by: John Baker | last post by:
Hi: Access 2000 W98! I have a table with numerous records in it, and am attempting to delete certain records that have been selected from it. These are selected based on the ID number in a...
4
by: Prince | last post by:
Hi All, Can anyone tell me how to Insert,Update and Delete a record into already existing DataTable? Looking forward for the reply... Thanx in advance... Regards,
1
by: Jürgen Bayer | last post by:
Hi, I just tried out the ObjectDataSource of ASP.NET 2.0. A simple application works with a GridView bound to an ObjectDataSource. The ObjectDataSource is set to a (factory) class...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
0
by: Gammazoni | last post by:
Hello, I have a code like that, which has been using by me, but now I need another one, which won't differ a lot, I hope. Please, analize it, I believe that here I'll find somebody with large luggage...
11
by: Ed Dror | last post by:
Hi there, I'm using ASP.NET 2.0 and SQL Server 2005 with VS 2005 Pro. I have a Price page (my website require login) with GridView with the following columns PriceID, Amount, Approved,...
3
by: Will | last post by:
Can someone help with code to delete multiple columns from an excel spreadsheet? I know which columns I need to delete. The code below will delete a single column but I'm not sure how to delete...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.