Remove link for linked table in access - ms-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

Related

Read Only linked table in Access to a SQL view - does not work

I have an ODBC connection created in MS Access 365. This is used to create a linked table in Access to a view in my SQL DB. I am using a SQL login to authenticate with SQL DB. The login has the datareader role set for that DB
If I make any changes to a record in the linked table in Access, those changes are also made in the SQL DB.
How can I avoid any changes in the Access linked table being propagated into the SQL DB?
You can add a trigger to the view like this:
CREATE TRIGGER dbo.MySampleView_Trigger_OnInsertOrUpdateOrDelete]
ON dbo.MySampleView
INSTEAD OF INSERT, UPDATE, DELETE
AS
BEGIN
RAISERROR ('You are not allow to update this view!', 16, 1)
END
You can also in a pinch add a union query, but it is somewhat ugly - you have to match up the column types. Eg:
ALTER VIEW dbo.MySampleView
as
SELECT col1, col2 FROM dbo.MySampleTable
UNION
SELECT NULL, NULL WHERE 1 =0
You can also create a new schema. Say dboR (for read only).
Add this new schema to the database. Then add the schema to the sql user/logon your using for this database. And then set the permissions to the schema to read only.
You have to re-create the view and choose the read-only schema for this view. On the access client side, I in most cases remove the schema default "dbo_" and just use the table (or view name) - you can thus continue to use the same view name you have been using in Access.

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>;

Modify linked SQL table name in Access 2013

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.

How to select temporary tables in Temporary Tables

Currently, I have some temp tables as this format "#A0089D2C", "#A0232241"
How could I select them to see what are its data?
I tried these queries as below:
Select * from #A0089D2C
Select * from tempdb.dbo.#A0089D2C
But I got the error:
Database name 'tempdb' ignored, referencing object in tempdb.
Database name 'tempdb' ignored, referencing object in tempdb.
Msg 208, Level 16, State 0, Line 1
Invalid object name '#A0089D2C'.
Please advise.
Thanks.
Technically, only that user who created the local temporary table can access it within the scope.
That means, local temporary table (# tables) can be accessed within the same scope by the same user while global temporary table(## tables) can be accessed among all the users until the last user session that references the table disconnects.
you can check table schema via below trick:
Right click on Tempdb database
Task > Export Data
Keep source database as TempDb
Select destination (Remember: you can not transfer data)
On Select source table and view form you will see "Edit mapping". Click on that to see table structure
but if you are really enthusiastic to see data in temporary table then check out this awesome post about viewing another session's Temporary table by Paul White
this should work, at least if the temp-table exists at the moment.
Select * from tempdb.dbo.#A0089D2C
See, temp tables are like the Schrodinger cat, they exists and they don't in the same time ;)

How to DELETE Records from Target Database in SSIS

Same database exist on two servers. I will call them Source and Destination for simplicity here. I need to compare records and delete those only exist in target but not in Source. I can't use Execute SQL as both databases exist on different Servers and there is no link between them. Can anyone propose a solution?
You could populate a table on the target with the IDs from the source table. Then use an Execute SQL task on the Destination database to delete rows from target table that do not exist in the table you populated. Eg, something like:
DELETE FROM TargetTable
WHERE ID NOT IN (SELECT ID FROM TableIDsFromDestination)
What you can do is create an Staging base in the Destination server where you are going to copy the information without look for references, after that you can do the compare directly in the same server.
I hope it helps.