Question:
How can I check the size of an SQL database?
Solution:
To do so, you must run a Stored Procedure, available in the database. To run it in E3, access a new Query’s settings, and select any table connected to the DB. On SQL tab, enable SQL’s direct edition and insert the following syntax: Exec SP_SpaceUsed
On Visualize tab, the Query will return the DB’s name, total size, and unallocated space.
To use this information at run time, you can create a script using the Query’s GetADORecordset method, as seen below:
Sub CommandButton1_Click()
Set RS = Screen.Item("Query1").GetADORecordset()
Campo1 = RS.Fields("database_name").Value
Campo2 = RS.Fields("database_size").Value
Campo3 = RS.Fields("unallocated space").Value
Msgbox Field1
Msgbox Field2
Msgbox Field3
End Sub