Sync table with mysql

Anonymous
2021-11-03T22:24:58.577+00:00

I have a fairly straight forward project I'm trying to complete. I would like to sync data or import on a schedule from a mysql db. The table would only involve 2 fields, and ideally the data in the mssql db would arrive based on a query that is executed (select field1, field2, from table, where field = 'x'). What would be the easiest way to accomplish this?

I currently run a 2012 sql server on prem with windows 2012. Any help would be appreciated.

Thanks

SQL Server Other
{count} votes

1 answer

Sort by: Most helpful
  1. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2021-11-04T01:29:49.513+00:00

    Hi @Anonymous ,

    Did you want to import data to a table on a schedule? If so, you can create a job to run below T-SQL.

    INSERT INTO table2 (column1, column2)  
    SELECT column1, column2  
    FROM table1  
    WHERE column1=’X’;  
    

    Please follow below steps.

    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'.
    6.Click on the 'Schedule' menu on the left of the New Job window and enter the schedule information (e.g. daily and a time).
    7.Click 'OK' - and that should be it.

    If I misunderstood, please let me know.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.