By using following code, we can find database size in AX using code.
static void dBSize(Args _args)
{
LoginProperty loginProperty;
ODBCConnection odbcConnection;
Resultset resultSet;
Statement statement;
SysSQLSystemInfo systemInfo;
str sqlStatement;
real size;
;
systemInfo = SysSQLSystemInfo::construct();
sqlStatement = strfmt( "SELECT size FROM sys.master_files where name = '%1'",systemInfo.getloginDatabase());
loginProperty = new LoginProperty();
loginProperty.setServer(systemInfo.getLoginServer());
loginProperty.setDatabase(systemInfo.getloginDatabase());
odbcConnection = new ODBCConnection(loginProperty);
statement = odbcConnection.createStatement();
resultSet = statement.executeQuery(sqlStatement);
while (resultSet.next())
{
size = str2int(resultSet.getString(1));
size = size*8 /1024;
info(strfmt("%1 MB",size));
}
}
static void dBSize(Args _args)
{
LoginProperty loginProperty;
ODBCConnection odbcConnection;
Resultset resultSet;
Statement statement;
SysSQLSystemInfo systemInfo;
str sqlStatement;
real size;
;
systemInfo = SysSQLSystemInfo::construct();
sqlStatement = strfmt( "SELECT size FROM sys.master_files where name = '%1'",systemInfo.getloginDatabase());
loginProperty = new LoginProperty();
loginProperty.setServer(systemInfo.getLoginServer());
loginProperty.setDatabase(systemInfo.getloginDatabase());
odbcConnection = new ODBCConnection(loginProperty);
statement = odbcConnection.createStatement();
resultSet = statement.executeQuery(sqlStatement);
while (resultSet.next())
{
size = str2int(resultSet.getString(1));
size = size*8 /1024;
info(strfmt("%1 MB",size));
}
}
No comments:
Post a Comment