sqlsql-serverssms-2012

SQL Server job for copying data from a database to another one


I am amateur in SQL Server jobs or procedures and i need to develop a job to copy data from a database to another one. if you know a little example that can help me to create it, i will really thankfull.

It should be like a function, that someones call the function (by the name) and it automatically copy data from a database to another one.


Solution

    1. Expand the SQL Server Agent node and right click the Jobs node in SQL Server Agent and select 'New Job'

    2. In the 'New Job' window enter the name of the job and a description on the 'General' tab.

    3. Select 'Steps' on the left hand side of the window and click 'New' at the bottom.

    4. In the 'Steps' window enter a step name and select the database you want the query to run against.

    5. Paste in the T-SQL command you want to run into the Command window and click 'OK'.

        INSERT INTO newTable
        SELECT * FROM oldTable
    
    1. Click on the 'Schedule' menu on the left of the New Job window and enter the schedule information (e.g. daily and a time).

    2. Click 'OK' - and that should be it.

    Check the animated gif by S.Mason

    enter image description here