I need to estimate the database size for prerequisite, so I'm trying to understand how does SQL Server store data in the example below.
In my SQL Server database, I have a table named InfoComp which contains 4 rows:
IdInfoComp : Integer Not Null (PK)
IdDefinition : Integer Not Null (FK)
IdObject : Integer Not Null (FK)
Value : NVarChar(Max) Not Null
I want estimate the table size. In real usage, I can get the average length stored in Value with this SQL query:
SELECT AVG(Value) FROM InfoComp
Result : 8
So, my calculation seems to be (in byte):
(Size(IdInfoComp) + Size(IdDefinition) + Size(IdObject) + AVG Size(Value)) * Rows count
( 4 + 4 + 4 + ((8 * 2) + 2)) * NbRows
But when I'm trying to apply this calculation in the real case, it's wrong. In my case, I have 3,250,273 rows so the result should be 92 MB, but MS SQL Report says:
(Data) 147 888 KB (Indexes) 113 072 KB and (Reserved) 261 160 KB.
Where am I wrong?
Try this...this gets me close. I used the msdn article to create . You can set the number of rows. This will do every table in the db including the indexes. Doesn't do columnstores yet and won't handle relationships. It will just apply the rowcount estimate to every table.