I am new to access and have mostly worked with SQL Server. I am trying to accomplish a task for our users and am not sure how to approach it.
We have a situation where the users need to manipulate some data in various access tables, then put the final results into one of several 'linked tables' that are defined in SQL Server and linked to access. The sql server tables will defined very generically with column names like 'col1', 'col2' etc to allow for different types of data to be uploaded.
What I would like to do is have some kind of macro or module that does this:
1) Lets the user select the source (access table)
2) Lets the user select destination (linked sql server) table
3) Lets the user map the columns he would like to copy from the source to the destination table. (If this is too difficult then just something that would copy the first x number of columns would work).
4) Deletes all pre-existing data from the target table
5) Copies all data from the source table to the target table.
Could someone give me an idea as to what would be the best approach or maybe even an example of some code that does something similar? Thanks in advance. We are using Microsoft Access 2010.
Related
I have two Database for example "Database1" another is "Database2" whose location at 'Libraries\Documents' at my pc. Now I want to select one column named it "Column3" where another column "ID" of Database1 equal to Database2. So how can I write this query? And also how can I get those data from different database and same or different location of database? please explain with query example. I found it only for SQL but not for Access database 2013.
Thanks in advance.
Did you try link tables from 2nd file into 1st file?
From one Access DB file you can link tables from various data sources, including all kinds of other databases or excel, csv, xml files, and then you can treat them as "linked table",
for all the local tables and linked tables you can easily join them and build up queries.
It is one of the many handy features that i like to use MS Access for quick and easy tasks.
Hope this helps.
I have a situation where I have an application that uses multiple SQL Server 2008 databases (all with different schemas - split by application function).
I now want to combine these schemas and data into a single overall application database (SQL Server 2008). I've searched for help on how to do this, but all the solutions I've seen have covered merging data from databases with identical schemas. In this case, there is no commonality in the schemas of the separate databases - all the tables are unique. For this, I just want to combine all the tables and data into a single database, and I'm really looking for a tool that will help me do it simply and easily.
Can anyone give some guidance on how this could best be achieved?
I guess you can create a script something like this ... in your Source database execute the following statement in with Results to Text selected
SELECT N'SELECT * INTO [dbo].['+ TABLE_NAME + N'] FROM [ServerName].[Database].['
+ TABLE_SCHEMA + N'].[' + TABLE_NAME + N']; ' + CHAR(10) + N'GO'
FROM information_schema.tables
WHERE TABLE_TYPE = 'BASE TABLE'
And it will generate the script as follows. all you need to do is copy it from results pane and paste it in query window , Target database context and job is done ....
SELECT * INTO [dbo].[TestTable] FROM [ServerName].[Database].[dbo].[TestTable];
GO
SELECT * INTO [dbo].[TableOne] FROM [ServerName].[Database].[Account].[TableOne];
GO
SELECT * INTO [dbo].[TableTwo] FROM [ServerName].[Database].[Account].[TableTwo];
GO
SELECT * INTO [dbo].[TableTHREE] FROM [ServerName].[Database].[Account].[TableTHREE];
GO
SELECT * INTO [dbo].[TableTHREE] FROM [ServerName].[Database].[HumanResource].[TableTHREE];
GO
SELECT * INTO [dbo].[TableOne] FROM [ServerName].[Database].[HumanResource].[TableOne];
GO
SELECT * INTO [dbo].[TableTwo] FROM [ServerName].[Database].[HumanResource].[TableTwo];
GO
Issues with this Script
1) Since you want to get tables from multiple schemas thrown into one
schema in the destination database there can be some duplicate Table
Name as I have shown in my above example.
2) Tables that has columns that references column in other
tables must me created after the table containing referecing column is
created.
I suppose you would not find such tool. You require custom functionality which is not very common. Therefore, I suppose nobody would make a tool for it. Your scenario is not very clear. I would see three ways of moving.
If this merge is going to happen once, then it is quite easy. You could export the tables in the form of a CREATE SQL statement, including data. You could use this tutorial to do it in SQL server. You should do this for every table and then run these scripts to create the tables into the new schema.
If you want to merge the databases contents in the target database in a regular basis, you have to create an SQL Server Job. This would have to execute the custom scripts which would pull data from the source databases and push them to the target database.
If you want to concatenate a number of smaller databases in a big data warehouse, then you are looking for the Business Intelligence Development Studio. You could use it to create an OLAP cube, concatenating data from the smaller databases in the big data warehouse.
Hope I helped!
I was working on an Access Application that has already an access database (tables, queries etc ) and a front end. I was trying to link access existing database tables with mysql. So, what I have done so far is, I have successfully linked the access tables with mysql using ODBC. My understanding regarding linking access table with mysql db was that, by doing so, I would have the same 'old' access table linked with mysql, but I was wrong. Instead after linking I got a new table (fields same as old) that has links with mysql database.
http://i.imgur.com/mfSF5hR.png [See this link showing old 'access' and new 'linked' table]
For instance, I had an 'Actor' table in access db (before linking) and after it I have 2 tables. One is the old access 'Actor' table and other is the new linked table named 'Actor1'. So, if I do changes in my old access table, the table in mysql doesn't get change but when I do changes in my new linked table i.e 'Actor1' changes happen in mysql table too.
Here the problem is my front end form/queries are using my access table the old one, so is there any way to use new 'linked' table without changing in the front end ?
Thanks in advance.
You just need to rename your Linked MySQL table (rename the link in Access only) so that it matches perfectly the name you were using for that same table before in Access. This way you won't have to change your forms, queries, reports.
There is no magic that happens in Access between local tables and linked tables. It's still up to you to move your data, make sure the MySQL table is designed the way you want it, maintain the links, delete old Access tables, etc.
good morning.
We need to copy tables from Access to SQL. Thing is the table names in the source vary from day to day.
I've followed the steps shown in the solution to this post How do I programmatically get the list of MS Access tables within an SSIS package?
The problem is this:
I changed variable names and that's all since the problem stated in that post is quite similar to mine.
I followed the steps and changed Country to a Table Name of my Access DB, lets say CITY. Problem is when the process Loops the tables in Access, the data copied to the tables in SQL is always the same. The data stored in CITY, it seems it's not changing tables, it always use the table provided to the OLE DB source (as shown in screenshot 14#) (the table name provided in the variable 'SelectQuery')
So I have all the tables in SQL created but they are all filled with the same information. Info coming from the same table (the one that has its name stated in the variable)
Thanks, any advice?
From reading the linked solution, it looks either incorrect, or missing one step. Right now, screenshot #14 specifies 'SQL Command from Variable', and 'SelectQuery' as the variable source; I can't see where SelectQuery is updated.
Solution 1:
Set the OLE DB Source to "Table name or view name variable", and set the variable in question to TableName (which is updated each iteration by the ForEach container)
Solution 2: Change SelectQuery to be an expression-driven variable, i.e. "select * from " + #[User:TableName]
you did realize that the table name on that example must match the sheet name on excel, right? So you probably have to do something like that on access.
Also, post more info. It seems that the value on your table variable is not being updated. Tell us how it should be.
I have a linked table set up in Access to an Oracle 10 enterprise server. It works great on my computer. But I'm trying to get a co-worker set up with the same functionality, and for some reason, she can't see all the columns in the table. It connects, refreshes, says it's linked, but not all the columns are there. Using a different client or sql on command line we can see the whole table. Just not in Access. The only difference is that I'm using Oracle 9g Client and she's using Oracle 10g Express. Any ideas?
Look into what HansUp stated about caching. There is one point I'd like to make. Ensure your co-worker is selecting from the same schema and same table. Multiple schemas (users) can have similar table names.
Example:
User a has table x with columns x,y,z
user b has table x with columns x,y
If you log in as user a and select * from x then the columns you will receive is x,y,z
if you log in as user b and select * from x then the columns you will receive is x,y
Either ensure you are logging in to the correct user or explicitdly state the schema you want in the select i.e. select * from a.x;
And the winner is... a table with more than 255 columns! For whatever reason, the columns that I needed for my query were available the first time I ran it, and were available to my machine in all subsequent runs. For my co-worker, for whatever reason, 2 of the columns we needed were considered in the 255+ category.
The work-around is to use a pass-through query on the linked table in Access. And yes, I agree - 255+ columns in a table/view is HORRID design. Not my fault, just need the data!!