views:

417

answers:

6

Hi All,

I have a huge database (800MB) which consists of a field called 'Date Last Modified' at the moment this field is entered as a text data type but need to change it to a Date/Time field to carry out some queries.

I have another exact same database but with only 35MB of data inside it and when I change the data type it works fine, but when I try to change data type on big database it gives me an error:

Micorosoft Office Access can't change the data type.

There isn't enough disk space or memory

After doing some research some sites mentioned of changing the registry file (MaxLocksPerFile) tried that as well, but no luck :-(

Can anyone help please?

A: 

It's entirely possible that in a database of that size, you've got text data that won't convert to a valid Date/Time.

I would suggest (and you may hate me for this) that you export all those prospective date values from "Big" and go through them (perhaps in Excel) to see which ones are not formatted the way you'd expect.

Phil.Wheeler
funny enough, I actually have! :(The data within the database has been automatically generated and all are definitely a date type.As for excel, at first I tried to open it with Excel, but Excel has a maximum number of cells, I think around 1.2Million, this data goes over that :(
Can I suggest migrating your data from Access into SQL Express or something? That's a crazy huge amount of data to trust to Access.
Phil.Wheeler
It would be a good idea, however I am a complete novice when it comes to any database other than Access, but if there is a simple step of converting this database into SQL it would be great.
Access has a 2gb limit, 800mb is not a crazy amount of data. I think it is safer to stay with Access if that is familiar, unless you, khalidfazeli, expect the amount of data to more than double.
Remou
no the amount of data wouldnt change anymore from now on, will only need a few queries which shouldn't add anymore than 200mb to it.
+1  A: 

One relatively tedious (but straightforward) solution would be to break the big database up into smaller databases, do the conversion on the smaller databases, and then recombine them.

This has an added benefit that if, by some chance, the text is an invalid date in one chunk, it will be easier to find (because of the smaller chunk sizes).

Assuming you have some kind of integer key on the table that ranges from 1 to (say) 10000000, you can just do queries like

SELECT *
INTO newTable1
FROM yourtable
WHERE yourkey >= 0 AND yourkey < 1000000

SELECT *
INTO newTable2
FROM yourtable
WHERE yourkey >= 1000000 AND yourkey < 2000000

etc.

Make sure to enter and run these queries seperately, since it seems that Access will give you a syntax error if you try to run more than one at a time.

If your keys are something else, you can do the same kind of thing, but you'll have to be a bit more tricky about your WHERE clauses.

Of course, a final thing to consider, if you can swing it, is to migrate to a different database that has a little more power. I'm guessing you have reasons that this isn't easy, but with the amount of data you're talking about, you'll probably be running into other problems as well as you continue to use Access.

EDIT

Since you are still having some troubles, here is some more detail in the hopes that you'll see something that I didn't describe well enough before:

Here, you can see that I've created a table "OutputIDrive" similar to what you're describing. I have an ID tag, though I only have three entries. alt text

Here, I've created a query, gone into SQL mode, and entered the appropriate SQL statement. In my case, because my query only grabs value >= 0 and < 2, we'll just get one row...the one with ID = 1. alt text

When I click the run button, I get a popup that tells/warns me what's going to happen...it's going to put a row into a new table. That's good...that's what we're looking for. I click "OK". alt text

Now our new table has been created, and when I click on it, we can see that our one line of data with ID = 1 has been copied over to this new table.
alt text

Now you should be able to just modify the table name and the number values in your SQL query, and run it again.

Hopefully this will help you with whatever tripped you up.

EDIT 2:

Aha! This is the trick. You have to enter and run the SQL statements one at a time in Access. If you try to put multiple statements in and run them, you'll get that error. So run the first one, then erase it and run the second one, etc. and you should be fine. I think that will do it! I've edited the above to make it clearer.

Beska
Sorry I am abit of a novice when it comes to SQL. My table is called 'OutputIDrive' mykey is 'ID' and it ranges from 0 > 1325210 How can I put that into SQL? I tried changing your source above but get the 'Syntax error in query expression 'ID >=0 AND ID < 662605' Thanks for your help.
A: 

Review the existing values in your Date Last Modified field to see if there are any which Access does not interpret as valid dates. You can create a new query, switch to SQL View and paste in this statement and substitute the name of your table for YourTable.

SELECT [Date Last Modified]
FROM YourTable
WHERE Not IsDate([Date Last Modified]);

Running that query should show you any Date Last Modified values which are not valid dates. Fix or remove the invalid values.

After fixing those values, perhaps Access will let you convert the data type of your Date Last Modified field.

If not, try a SELECT ... INTO statement to copy the entire table into a new blank database. Then you can use the CDate() function to convert your Date Last Modified values from Text to Date/Time as part of the SELECT statement. The form for a SELECT...INTO statement is:

SELECT field1[, field2[, …]] INTO newtable [IN externaldatabase] FROM source

(Look in Access Help for more details on the SELECT...INTO statement.)

Say your new database is C:\Access\NewDB.mdb, and in addition to Date Last Modified your table has two other fields named field1 and field2:

SELECT field1, field2, CDate([Date Last Modified]) AS Date_Last_Modified
INTO YourNewTable IN 'C:\Access\NewDB.mdb'
FROM YourTable;

If it works, you can rename or delete your old table and import the copy you made in the new database.

Make sure to first create a backup copy of your original database in case anything goes wrong. Good luck.

HansUp
Thank you soo much! this worked perfect! just what I needed, :)
A: 

Assuming that the error message is accurate, you're running up against a disk or memory limitation. Assuming that you have more than a couple of gigabytes free on your disk drive, my best guess is that rebuilding the table would put the database (including work space) over the 2 gigabyte per file limit in Access.

If that's the case you'll need to:

  1. Unload the data into some convenient format and load it back in to an empty database with an already existing table definition.

  2. Move a subset of the data into a smaller table, change the data type in the smaller table, compact and repair the database, and repeat until all the data is converted.

If the error message is NOT correct (which is possible), the most likely cause is a bad or out-of-range date in your text-date column.

Larry Lustig
A: 
  1. Copy the table (i.e. 'YourTable') then paste just its structure back into your database with a different name (i.e. 'YourTable_new').

  2. Change the fields in the new table to what you want and save it.

  3. Create an append query and copy all the data from your old table into the new one.

Hopefully Access will automatically convert the old text field directly to the correct value for the new Date/Time field. If not, you might have to clear out the old table and re-append all the data and use a string to date function to convert that one field when you do the append.

Also, if there is an autonumber field in the old table this might not work because there is no way to ensure that the old autonumber values will line up with the new autonumber values that get assigned.

Jason
Huh? Of course you can keep the same Autonumber values. Just append the old Autonumber field to the new Autonumber field. The Jet/ACE Autonumber data type is just a Long Integer field with a special type of default value (and a few other restrictions, such as not being editable once the record is created), so you can append any value to the field in a new record as long as it doesn't violate the index for the existing data.
David-W-Fenton
A: 

You've been offered a bunch of different ways to get around the disk space error message.

Have you tried adding a new field to your existing table using Date data type and then updating the field with the value the existing string date field? If that works, you can then delete the old field and rename the new one to the old name. That would probably take up less temp space than doing a direct conversion from string to date on a single field.

If it still doesn't work, you may be able to do it with a sceond table with two columns, the first long integer (make it the primary key), the second, date. Then append the PK and string date field to this empty table. Then add a new date field to the existing table, and using a join, update the new field with the values from the two-column table.

This may run into the same problem. It depends on number of things internal to the Jet/ACE database engine over which we have no real control.

David-W-Fenton