I'm having an access tool where I'm importing an excel file with table information. The system is creating a new table with this info with column fields (F1,F2,F3, etc.) and under it there is 10 lines with data and after that a table. I need the information from this table to be appended in another table in Access. I'm having the code and the append query, but sometimes some of the columns in excel file are change their places and this is a problem for my table 2. I would like to ask you is it possible somehow to change automatically the nameing of the column fields in the first table when I'm importing the info from the excel sheet.
Thank you in advance! - Here is a screenshot. The yellow one to go to the grey one.
Related
To be more specific. I have a table that contains an attached file (added by a user within a form) I need to use the data in that file to update a table to be used in other queries. *fingers crossed
I have a package, that picks excel file from a location and loads to a table in sql server.(The Excel file is derived from another package)
The Excel file has columns with name A,B,C,D.
I want the columns to be aligned like A,B,D,C ( C & D sequence changed). Is there a way I can achieve this in SSIS? The person dropping the file does not want to manually change it.
Currently I have data flow as:
Excel Source Plus --> Row Count --> OLEDB Destination
Thanks :)
You can map fields in your destination in any order you wish. The columns can be in different positions or even have different names.
I have a MySql database with 170 entries already. The rows are auto incremented for the primary id. I added an additional column and want to fill that column with data that corresponds with the existing information. I already have the csv file with the data in the correct order. I am using GoDaddy. I tried importing the csv file but instead of adding the data inline with the existing data, it added the imported data to the end thus creating more id's which I didn't want to happen.
EDIT:
I'm sorry but I can't figure out how to add/show the csv/table here so this is the only way I could think of visually showing everyone whats going on and how it needs to be.
When I tried to import the csv for the last column it did this:
Not how I wanted it
I was trying to achieve this. The data in the last column is in the same row as the corresponding name in the first column:
How I wanted it
As it stands, I am currently looking to import data from an Excel spreadsheet into a table on a monthly basis. The header row in the spreadsheet contains the date that the original query was run.
I have one master table in access consisiting of multiple files. I would like to set up an automated process to capture the date in the header upon import, and then record it in a field for every new record that was imported.
There are two caveats here:
Spreadsheet sizes will vary depending on where data exists.
I have no control over how the data is provided. Fields that contain no data for the month will not populate to the spreadsheet.
Less frequently fields will be added that do not exist.
So far I have been identifying these new additions manually and creating a new field for them at the end of the field list. I realize that this is very inefficient and I would like to automate it, if I can.
Does anyone have any insight? Any assistance would be greatly appreciated.
OK, here's the steps you'll want to take.
Create a link from Access to your Excel spreadsheet. Access will now see this as a table.
Create a make table query using the Excel table as the source and adding the date (derived from a sub-query) as an additional field.
Then run the query. This will automatically create all the fields.
If, however, you need to create new fields in an existing table, then you'll have to use VBA, read each header in the Excel table, compare it to the schema of the existing table, and execute an alter table query to add the field.
Good luck
I am currently experiencing difficulties when trying to append data to existing tables.
I have about 100 CSV files that I would like to create a single table from; all the tables have different column structures but this isn't really an issue as the associated field names are in the first row of each file.
First, I create a new table from one of the files indicating that my field names are in the first row. I change the particular fields that have more than 256 characters to memo fields and import the data.
I then add to the table the fields that are missing.
Now, when I try to append more data, I again select that my field names are in the first row, but now I receive a truncation error for data that is destined for the memo fields.
Why is this error occurring? Is there a workaround for this?
edit
Here is an update regarding what I've attempted to solve the problem:
Importing and appending tables will not work unless they have the exact same structure. Moreover, you cannot create a Master table with all fields and properties set, then append all tables to the master. You still receive truncation errors.
I took CodeSlave's advice and attempted to upload the table, set the fields that I needed to be Memo fields, and then append the table. This worked, but again, the memo fields are not necessarily in the same order in every data file, and I have 1200 data files to import into 24 tables. Importing the data table by table is just NOT an option for this many tables.
I expect what you are experiencing is a mismatch between the source file (CSV) and the destination table (MS Access).
MS Access will make some guesses about what the field types are in you CSV file when you are doing the import. However, it's not perfect. Maybe it's seeing a string as a memo or float as a real. It's impossible for me to know without seeing the data.
What I would normally do, is:
Import the second CSV into it's own (temporary) table
Clean up the second table
Then use an SQL query to append those records from the second table to the first table.
Delete the second table
(repeat for each CSV file you are loading).
If I knew ahead of time that every CSV file was already identical in structure, I'd be inclined to instead concatenate them all together into one, and only have to do the import/clean-up once.
Had a very similar problem - trying to import a CSV file with large text fields (>255 chars) into an existing table. Declared the fields as memo but were still being truncated.
Solution: start an import to link a table and then click on the Advanced button. Create a link specification which defines the relevant fields as memo fields and then save the link specification. Then cancel the import. Do another import this time the one you want which appends to an existing table. Click on the Advanced button again and select the link specification you just created. Click on finish and the data should be imported correctly without truncation.
I was having this problem, but noticed it always happened to only the first row. So by inserting a blank row in the csv it would import perfectly, then you need to remove the blank row in the Access table.
Cheers,
Grae Hunter
Note: I'm using Office 2010