Swati_Srivastava-MSFThi, This SP works very nicely thank you. Two questions please though:
1) Could you please advise what are the minimum permissions needed to execute it, so that I can grant only those to the maintenance user that will execute the the SP
2) Is it possible to delete the data from AzureSQLMaintenanceCMDQueue instead of creating and deleting the table every time?
The reason I am asking question 2 is that I tried to avoid granting the user DDLAdmin permission and instead created the table AzureSQLMaintenanceCMDQueue in the db permanently and rather than dropping the table, I delete the data from it. This allowed me to granted rwd permission on this specific table. However I then encountered a permission error with respect to tempdb..AzureSQLMaintenanceCMDQueue, which I dont know how to get around.
"Msg 1088, Level 16, State 11, Procedure dbo.AzureSQLMaintenance2, Line 500 [Batch Start Line 0]
Cannot find the object "AzureSQLMaintenanceCMDQueue" because it does not exist or you do not have permissions.
"
Im kind of stuck. Appreciate any help
Thank you!