Syntax to find the used space and free space of the Data
file in a database(SQL Server). Following queries didn't
give the exact Used space and Free Space Information
sp_spaceused;DBCC showfilestats;exec
MyDbName.dbo.sp_spaceused;SP_HELPFILE

Can any one tell me the query for how to find the exact
used data file space and free space in a Data File?

Answers were Sorted based on User's Feedback



Syntax to find the used space and free space of the Data file in a database(SQL Server). Following..

Answer / narasimha

SELECT name ,size/128.0 - CAST(FILEPROPERTY
(name, 'SpaceUsed') AS int)/128.0 AS AvailableSpaceInMB
FROM sys.database_files;

Is This Answer Correct ?    4 Yes 1 No

Syntax to find the used space and free space of the Data file in a database(SQL Server). Following..

Answer / allah baksh

exec sp_spaceused [schema.tablename] this will give you
data file and the size available

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

How to create nested stored procedure?

0 Answers  


How to turn off warning messages during php execution?

0 Answers  


Explain trigger and its types?

0 Answers  


What are page splits?

0 Answers  


How to get the query of a table in sql server?

0 Answers  


What are the different types of sub-queries?

0 Answers  


When we are using this query to shrink the log file,what exactly it will execute internally? Do we lose any data when we run this script? which data it will truncate in the log file and where it is saved. Please let me know... USE DatabaseName GO DBCC SHRINKFILE(<TransactionLogName>, 1) BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY DBCC SHRINKFILE(<TransactionLogName>, 1) GO

1 Answers   Cognizant,


What are the different types of backups that exist?

0 Answers   ADITI,


How to find table changes in sql server?

0 Answers  


How you would rewrite the sql query to return the customerid sorted numerically?

0 Answers  


plz tell me the new features of sqlserver2000,sqlserver2002,sqlserver2005

3 Answers  


Difference between LEN() and DATALENGTH() in sql server ?

0 Answers   HCL,


Categories