sql server - How to retrieve results from 'DBCC SHOWFILESTATS' with ODBC? -
i need find relative amount of space available in sql server database using odbc connection.
i wanted try using dbcc showfilestats not return results.
having read inf: processing dbcc commands in odbc applications understood because not select statement. puzzled me statement didn't return info either (contrary paper).
i tried using temporary table:
declare @filestats table ( fileid int, [filegroup] int, totalextents int, usedextents int, name varchar(255), [filename] varchar(max) ) insert @filestats execute('dbcc showfilestats') and selecting table in same sqlexecdirect.
select 1-convert(float, sum(usedextents))/convert(float, sum(totalextents)) freedataspace @filestats this resulted in error 24000 (and made sure there no other open statements).
is there alternative way retrieve information?
apparently there's alternative way something.
what worked me was:
select convert(float, (sum(f.size) - sum(fileproperty(f.name,'spaceused')))) / sum(f.size) sys.sysfiles f join sys.database_files db_f on f.fileid = db_f.file_id db_f.type = 0 it works through odbc , gives same results original solution when executed in management studio.
Comments
Post a Comment