Hi Alexander,
I mentioned in the post that it’s not possible to run USE command on Azure SQL so that is not an option. Basically the maintenance job as far as I know can be run only on the master database.
This is what you get when you try to run USE in the maintenance job.
- 14:33:59 : Starting maintenance job “tcdev - sp_updatestats”. Server “DESKTOP-F8RTRFJ”. Account “SYSTEM@WORKGROUP”. App v.“12.6.3”.
- 14:33:59 : Running SQL maintenance script.
- 14:33:59 : ERROR: Job execution error: One or more errors occurred. > USE statement is not supported to switch between databases. Use a new connection to connect to a different database. Server name: “DESKTOP-F8RTRFJ”.
- 14:34:00 : Deleting temporary files.
- 14:34:00 : ERROR: Job “tcdev - sp_updatestats” finished with “1” errors.