Updating an Access table from a SQL server table transaction - sql-server

My goal is to write an update trigger within a SQL server DB table. The function of this trigger is to update an Access database table with the same information that is being updated in the SQL server.
Is this even possible?

You have to use Linked Server to create communication between sql server instance and access database...

or make use of OPENROWSET function

Related

Automatically update SQL Server database from tables in MS Access

I'm new to SQL Server and trying to automatically update tables in SQL Server from tables in MS Access.
I have an Access database of metadata that must be kept updated for sending records to other groups. I also have a database in SQL Server which also has these same metadata tables. Currently these tables in the SQL Server database get updated manually by exporting the Access tables as Excel files, and then importing them into the SQL Server tables.
It's not the most efficient process and could lead to errors in the SQL Server database if someone forgets to check that they are using the most recent data from Access. So I would like to integrate some of the tables from Access to my database in SQL Server. Ideally I would like for the tables in my SQL Server database to be updated whenever Access is updated or at least update the tables automatically in the SQL Server database when I open it.
Would replicating the Access tables be the best? I am using SQL Server 2014 Developer so I think I have this capability. From my understanding, mirroring is for an entire database not just pieces of it. However, I do not want to be able to alter the metadata from SQL Server and have it reflected in Access. I cannot tell if reflecting the tables would do this...?
I also looked at this post about writing multiple insert statements but was confused (What is the best way to auto-generate INSERT statements for a SQL Server table?). Someone else suggested importing all the data into SQL Server and then using an ODBC driver to connect the two, but I'm also not sure how this would update the database in SQL Server anytime Access is updated.
If you have any suggestion and a link to easy to follow tutorial I would really appreciate it!
Thanks
In Access, go to 'External Data', ODBC Database, and connect to the SQL Server database directly - make sure you select 'Link to the data source by creating a linked table' on the first page of the wizard. Now, this linked table is available in Access, but is actually the SQL Server table.
Get rid of the local Access tables, using the new linked tables in their place in whatever queries, forms, reports, etc that you have in Access.
Now, any changes to the tables you see in this Access db ARE changes to the SQL Server database.

How to copy all rows from one SQL Server table to a table on a different SQL Server

I have a database in SQL Server 2008 and the same database (backup) in SQL Server 2016. All the schema and tables are exactly the same.
I need to copy all rows from a table in SQL Server 2008 to the same table in SQL Server 2016. How to achieve this?
Linked Server
BCP
Create new DB, copy the data to that new DB, back it up, restore on target server as a new DB, update the data from Target new DB to existing target DB.
create your table on the target server using your scripts from the Script Table As / Create Script step
on the target server, you can then issue a T-SQL statement:
INSERT INTO dbo.YourTableNameHere
SELECT *
FROM [SourceServer].[SourceDatabase].dbo.YourTableNameHere
If it's a 1-time extract only, I'd not bother setting up a linked server, but instead I would use the Export Data functionality in SQL Server Management Studio.
To do this, right-click the Source Database in SSMS, then select "Tasks" -> "Export Data". You can use the wizard to specify exactly what you want to export (I.e. one or more tables, or even data using a query), specify the target, and select whether you want to run the package or save it for later use.
Another Option you can use OpenRowSet like:
SELECT * into insertTable FROM
OPENROWSET('SQLNCLI', 'Server=ServerIP\ServerExtentionNameIfhas;Database=dbname;Uid=uname;PWD=password;'
,'SET FMTONLY OFF;SET NOCOUNT ON;SELECT * FROM fromTable')
this will create automatically a table name which is inserTable and copy all rows into it.

update a column of table in sql server from ms access

I have a table in sql server, and another table in ms access. The two tables are different tables. but one column in sql server need fresh data from the table in ms access. Is that possible that when ms access have update or new record, the table in sql server will be updated automatically.
Absolutely yes! Just link the SQL Server table in Access via ODBC (after setting up a DSN). On ribbon, see External Data tab (ODBC).
Then, run an append and update query in the After Insert or After Update VBA trigger event on form from the local table into the linked table.

Creating a snapshot database to another SQL Server

I'm trying to save the values of several columns of one table to another table on a different server. I am using SQL Server. I would like to do this without running external programs that query from this database and insert the results into the new database. Is there any way to do this from within the SQL Server Management Studio?
This is a recurring event that occurs every hour. I have tried scheduling maintenance tasks that execute custom T-SQL scripts but I'm having trouble getting the connection to the remote server.
Any help would be appreciated.
If you can set up the remote server as a linked server you should be able to configure the SQL Server Agent to execute jobs that contain queries that access tables on both the local and linked server. Remember that you might have to configure the access rights for the account used to run SQL Server Agent so that it has permissions to read/write tables on both servers.
This practice might not be without issues though as this article discusses.
You can use a 4 part name like;
INSERT [InstanceName].[DatabaseName].[SchemaName].[TableName]
SELECT * FROM [SourceInstanceName].[SourceDatabaseName].[SourceSchemaName].[SourceTableName]
But first you will have to set the remote server as a linked server as so;
https://msdn.microsoft.com/en-us/library/aa560998.aspx

How to transfer a SQL Server table from one server to another

What is a good way to transfer a table from one SQL Server instance to another server with an available FTP?
Use 'Generate Scripts' to script table creation and use the SSMS Tools' 'Generate Insert Statement' feature to create a script to populate the table. Simple, ad completely disconnected.
And alternative would be to backup the DB, restore it to a parallel DB on the new server, and copy from DB to DB (via SELECT INTO)
Have you tried using a linked server from server A to server B?
Here's one way (using TASKS via SSMS): http://msdn.microsoft.com/en-us/library/ms142159.aspx
Here's another way (using SSIS): http://msdn.microsoft.com/en-us/sqlserver/cc511477.aspx

Resources