I have created a linked server to copy data from one database to another and this worked well when I manually write the query and execute it. But I want this to be scheduled to happen automatically. Should I use linked server for this or is there a better way to implement it?
If you have SQL scripts to transfer data, you can use SQL Script job step in a new SQL Server job.
I've created a step by step short tutorial showing how to create SQL Server job which executes a SQL stored procedure periodically according to the assigned execution schedule.
You should try using the scheduled jobs, with SQL Server Agent.
In short, you will need to created a stored procedure that executes the moving code you need.
Then, from Databases > SQL Server Agent > Jobs, you can create a new scheduled job to make it run when you need it to.
Related
I would like to create a stored procedure that calls a SQL Agent job, which will in turn call an SSIS package. The job and the SSIS package will reside on the same database server. However, I would prefer that the stored procedure resides on a different database server. The reason behind this is that we have an app that will be calling the sproc. I don't want to give it access to the database where the SQL Agent job and SSIS package reside.
How would I go about doing this?
In a different database in the same instance is very simple. Just use a doted name (db_name.schema_name.object_name).
In a different instance, you must create a linked server and use a doted name like :
instance_name.db_name.schema_name.object_name
I have a list of three stored procedures that need to be ran daily on a number of separate SQL databases. Each database is named differently, but the stored procedures on each are the same.
I have extremely limited knowledge on anything other than basic queries, but was thinking I could have a SQL Server Agent job on a database I set up as Master. Then I have that server push that job to the other databases once I configure those as Targets. My issue is that in thinking through this, the database names are different and within the SQL Server Agent wizard I can only set the database to what's currently on master instance.
What would be the best approach to executing this looping through servers to run the stored procs?
What you're looking for is a linked-server. They allow servers to be linked so that you can call objects from one server to another. They are very easy to setup. In your case, you'll need to create 3 linked-servers on the main server, which will be used to schedule the job. A linked-server will allow the main server to link to listed servers. Here are tutorials of how you can create a linked-server.
Once you've created a linked-server you'll simply create a job that will execute all 3 sprocs, something like this:
EXEC [server1].[database].[schema].[sp_name];
EXEC [server2].[database].[schema].[sp_name];
EXEC [server3].[database].[schema].[sp_name];
I have a host on a server and that contains an SQL Server Database.
I have another server in another country and i want have a backup from the database every 5 minutes or after each transaction only insert new row to another database.
After some research i found out i can use linkedservers for this goal.
Is this procedure works for me for doing this operation?
I don't know what the linkedserver will do for you.
You are connected from both server via a vpn?
You are in different network (domain) probably?
If you are using a linked server, it means you will probably create trigger or stored proc. You will have to configure msdtc (for trigger).
You can use :
Replication
Log shipping
Custom replication process
I had to configure 2 times a replications to move the data from a server to another, than manage these data with trigger. It was easier to work on the data localy
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
I need to pull data from one SQL 2005 Express database to another and I need to do this periodically. It is not a straight copy from one table to another, but I would use different views from the source table. I also need to do this periodically.
My first idea is to write a small application in C# and run it somehow in every hour or so, but I would like to keep this data manipulation logic as close to the database server as possible.
What are the tools and features that I can use SQL Server 2005 Express?
Add linked server: Server Objects->Linked Servers
a) Write script to copy (you don't prefer this method, I think)
b) Create package SSIS in VS and execute it with different parameters (you can pass input parameters to package)
c) Use wizard (Import/Export) than save this task as package (as file to edit or to server to execute)
I think c) is your case.
EXPRESS has no SQL Server Agent, so use other server (enterprise or standard editions) to execute your package periodically