I need to automate the restore of a database each night from a backup but I want to first check if there is enough disk space. In the below Microsoft link it says the verifyonly command is able to do this "Checking for sufficient space on destination devices" but I can't find any examples online of how to use verifyonly with a destination to test. How can I do this?
SQL Server – How to Check Disk Space Before Overwriting a DB with Restore Command
backuprestoresql server
Related Question
- SQL Server Backup – Use Different Domain and Username in BACKUP LOG Command
- SQL Server – Required Permissions for UPDATE STATISTICS with ROWCOUNT
- Is SQL Server Data Tools a Paid or Free Product?
- SQL Server – Credential Password vs Secret Difference
- Sql-server – Restore ALL databases with sqlcmd in SQL Server (Express, Docker, 2017)
Best Answer
You can use this syntax:
In case of insufficient space you'll get this error:
This is not an optimal way to check for disk space because this will not only check for a
space
available and you will wait the wholedatabase backup
check to finish.You can use your own code like this, for example, here I use
xp_fixeddrives
to check free space: