We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

karthick.k
Posts: 57
Joined: Tue Jul 14, 2015 1:30 pm

How to get the SQL Database size in the installer

Hello,

We are having a scenario, where when we are running the upgrading an environment we will taking a backup of the database.We would like validate to see if we have space to store the backup, so we are wondering how we can get the size of the database and compare it with the available space.

Please help us on achieving this.

Thank you
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: How to get the SQL Database size in the installer

Hello,

To get the size of the database you can create a sql query in the SQL Page. For example, the following script can retrieve the size of the selected database:

Code: Select all

SELECT SUM((size*8)/1024) SizeMB FROM sys.master_files WHERE DB_NAME(database_id) = 'Selected_database'
In order to get the values of Drive Space Information, you can set the AiEarlyValidate property in the custom actions page using the predefined Set installer property.

The drive space requirements validation are done by Windows Installer through some standard actions which stores their values in the following properties:
  • [PrimaryVolumeSpaceRequired]
    [PrimaryVolumeSpaceAvailable]
    [PrimaryVolumeSpaceRemaining]
The sample project is attached to this thread, so if you are interested to take a look directly at my project, you are more than welcome to download the ZIP file.

If you have any questions, please let me know.

Best regards,
Dan
Attachments
Test SQL Connection Sample and Create New Database.zip
(6.51 KiB) Downloaded 272 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
karthick.k
Posts: 57
Joined: Tue Jul 14, 2015 1:30 pm

Re: How to get the SQL Database size in the installer

Thank you for you suggestions :).

We will try implementing the suggestion and see how that works for us.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: How to get the SQL Database size in the installer

You're welcome,

Please let me know if you need any help.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”