sql server database file size already 4 gb but not so much data in it
I checked the size of the file itself - it said it's 4.02 GB. I checked the size me开发者_StackOverflowntioned in properties of the database using SSMSE - it said the size was somewhere above 4000 MB.
I then executed sp_spaceused and it said that the file size was above 4500 MB and the unallocated space was close to 4100 MB.
I'm a little confused as to how this works. I'm using SQL Server Express so I need to monitor the db size to figure out if it's reaching its limit. How do I figure out the in-use db size?
You're on the right track for analyzing the file use. The actual numbers will vary slightly for different reasons. For example, the file size greater than 4500 MB and the unallocated space of 4100 MB from sp_spaceused include the transaction log file (file with .ldf extension). The tran log is separate from your user data; so, for user-data space analysis exclude the space allocated for the tran log.
The file size represents disk space that has been reserved for your database, but not necessarily used by the database. You have to look at the SQL Server information to learn how much of that file is actually in use.
Your database size will reflect the approximate size of the database. This is the amount of file space that is allocated to the database. The unallocated space is the amount of file space that is not in use by the database and is available for new data. So, your current space used is approximately 400 MB (4500 - 4100 MB). And, the unused space is about 4100 MB.
if storage is your problem, try using SHRINKFILES or SHRINKDATABASE on the database regularly. After that, you can check the size of the file. Good luck.
精彩评论