Modify linked SQL table name in Access 2013 - ms-access

I have a SQL table linked in Access. I'd like to know how to change the linked table object to reference a different table with the same design but another name. For example, I link Table1 and create forms with it, and now need to change it to Table2.
There doesn't seem to be an easy way to do this.
The table Description in Design View contains all the linked database and table information but it's not editable.
Using the Linked Table Manager, I can change the database the table comes from, but the tables in both databases need to have the same name.
I can create a query with Select * From Table1 and change it to Select * From Table2 to switch tables, but I don't want to use a workaround if I don't have to.

Remove the linked table, and use DoCmd.TransferDatabase to recreate the link with different names:
DoCmd.TransferDatabase acLink, "ODBC", your_ODBC_String, acTable, _
"schema.source_table", "target_table"
You can look up your_ODBC_String from existing linked tables.
Add the StoreLogin:=True parameter if needed.

Related

How can i import a schema of a table from one database to an existing table in another without altering the data in it?

I want to import/copy a schema of a table from e.g. "DB1 database" another table in "DB2 database" without doing anything to the data in it. When I try to import the structure to the existing table it gives an error:
" #1050 - Table 'access_logs' already exists "
In phpmyadmin Go to 'Opeartions' Tab and then go to 'Copy Table to' section
In that select the database in which you want to copy the table and give a name to the table.
You can choose options of Structure or Structure with data as per your requirements.

MySQL selecting columns from a specific table

I'm learning MySQL and this is probably the most basic of the basic questions I could ask, but I want to make sure I understand the syntax.
I have a MySQL script that created three different databases. If I wanted to select all fields from a specific database's table, I would use
SELECT * from database1.table1
correct? Or would it just be
SELECT * from table1
and if I wanted to select only two fields from another table, would it be
SELECT field1, field2 from database1.table2
or again just the table name?
Both forms are actually fine. In SQL you can qualify names to specify explicitly where a db object is located. This is useful for instance if you have a table2 in 2 different schemas (which is the correct term instead of "database", btw).
As it has been mentioned you can set a default schema to avoid having to add a schema to a reference (like your table2) all the time. If there is no schema given then the default schema (set with the USE schema command) will be taken instead. You still can use an explicit schema (either what is set as default or any other) if you like. This will help when you want to access an object which is not in the default schema.

Unable to refresh a local table created from linked table

I am new to access database.
I created a linked table (linked to an excel file)
I them created a local table which is just a filtered table from the linked table. (same table just filtered for some records.)
The issue I am running into is that I am not able to refresh this local filtered table. The steps I am following are :
Refresh linked table using 'linked table manager'
Refresh the local table (filtered version of linked table) using linked table manager and the refresh button in the menu bar.
While my linked table gets refreshed, this filtered table does not get refreshed.
Can someone suggest what I can do?
Thanks in advance
You might want to use a query rather then your local, filtered, table.
If you want to keep your current structure try this
Create -> Query Design -> click on SQL on the bottom right -> paste the following code in
SELECT * INTO local_filtered_table
FROM linked_table
WHERE <put your conditions here>;
Then run this query each time you update your linked table.
Or you can do as Rene suggested and just make a query instead of a local table which would look something like this.
SELECT *
FROM linked_table
WHERE <put your conditions here>;

ALTER ms-access table that is locked

I am trying to add a column to a table in an ms-access backend which is being used by multiple ms-access front-ends. When I try to add a column to the table like so (or with DAO):
sql = "ALTER Table MyTable " & _
"ADD COLUMN NewCol Integer "
CurrentDb.Execute (sql)
I get an error, and Access complains that the table is already locked by another user.
Is there a way to ALTER a locked table?
If you can't, how do you handle modifying a backend table that is always in use? Just wait until everyone goes home for the weekend? Are there some admin tricks that I can use to avoid this in the future?

Remove link for linked table in access

Had created a linked table in MS ACCESS 97. Need to remove the link and make the table static so that, even if the data in backend db is removed or altered, this should not affect the table data in MS Access.
Use a "make table" sql query in order to get the data into a local table then you can delete your linked table, SQL something like:
SELECT * INTO LocalTable FROM LinkedTable