Vaalar
asked on
sp_spaceused and Delphi
Hi I would like to use sp_spaceused procedure to check the size of my database.
I want to save the information about database size in some parameter and if database is larger than 3GB i will erase some data.
Can you show me how can i do it in Delphi.
Thx.
Vaalar
I want to save the information about database size in some parameter and if database is larger than 3GB i will erase some data.
Can you show me how can i do it in Delphi.
Thx.
Vaalar
if you are using DBExpress try
var
DatabaseSize: string;
MyProc : TSQLStoredProc;
MyProc := TSQLStoredProc.Create(nil) ;
try
MyProc.SQLConnection := Your Connection;
MyProc.ExecProc;
DatabseSize := MyProc.FieldByName('databa se_size'). AsString;
finally
FreeAndNil(MyProc);
end;
Other components should just work in a similar manner
var
DatabaseSize: string;
MyProc : TSQLStoredProc;
MyProc := TSQLStoredProc.Create(nil)
try
MyProc.SQLConnection := Your Connection;
MyProc.ExecProc;
DatabseSize := MyProc.FieldByName('databa
finally
FreeAndNil(MyProc);
end;
Other components should just work in a similar manner
you have to specify the stored procedure name after setting the connection i.e
MyProc.SQLConnection := Your Connection
MyProc..StoredProcName := 'sp_spaceused';
MyProc.SQLConnection := Your Connection
MyProc..StoredProcName := 'sp_spaceused';
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Note that the result is returned in Bytes so divide by 1024 to get MB
However, you should be aware that you will not regain the space until after you backup and shrink the database. In other words, if you execute the procedure and then delete some data, you will still get the same results if you execute the procedure again before you shrink the database . . . even if you execute the procedure the next day. That could result in your progressively deleting a whole lot more data than you think you are going to.