I have a similar requirement but the other way. I.e I have a table in an Azure SQL database, which we need to copy data from the Azure SQL database to an on-premise SQL Server database. The table refresh needs to be done once a day.
I am planning to create a linked server from the on-premise machine to Azure SQL, and then create a SQL Server Agent job to query the Azure SQL database from the on-premise server, download the data to .csv
file, drop the existing table and re-create the table again and import the data from the .csv
file.
Is this approach feasible? My table is very small and growth is very minimal. Please suggest if there is any easier way to do this task.
The approach you suggested is correct, but it can be lengthy one. instead of downloading data dropping table and again uploading data as @siggemannen suggested you cand directly insert the data with below script.
This will delete the records from table and insert the records from linked server table every time whenever SQL job will execute.
SUCCESSFULL EXECUTION: