For those of you who have tried SQL Azure Data Sync you likely know that the way that we execute synchronization from SQL Server to SQL Azure is through the use of SQL Agent. One of the handy parts of SQL Agent is the ability to schedule synchronization based our your own requirements. However, in some cases you actually want to execute synchronization based on some event that occurs within the database or even through an external application. For that, there is a handy stored procedure called sp_start_job within the MSDB database which you can call to execute synchronization. For example, I created a sync relationship between SQL Server and SQL Azure database using my AdventureWorks database and as a result there was a SQL Agent created called 'SyncToSQLAzure-Sync_AdventureWorksLT2008'. Using this, all I need to do is go to the msdb database (use msdb) and execute the following SQL:
exec sp_start_job 'SyncToSQLAzure-Sync_AdventureWorksLT2008'
If you want to get information on the job, you can also use sp_help_job.