I am surprise with one of my findings that using a FORMAT ()
does have very big impact on the row size and data size. It is almost 250x more of the size of not applying FORMAT ()
.
My question is:
1) Why does using FORMAT()
have such big impact on the size? To me, is just 1.23 vs $1.23 difference, which is probably 1 character difference. And does it matter with such huge size?
2) Why do we still be encouraged to use FORMAT()
in SQL server instead of using string concatenation as below. Since below is only 2X data size, and using format returns 250x data size. OR is that data size is not a critical measurement?
SELECT '$' + CONVERT(varchar(10), UnitPrice) FROM Sales.SalesOrderDetail;
3) Does having data size of 464MB means i will be returning 464MB of data to client?
========================================================
Below is my findings with AdventureWorks2012 database.
SELECT UnitPrice FROM Sales.SalesOrderDetail;
Actual Number of Rows: 121317
Estimated Number of Rows: 121317
Estimated Row Size: 15B
Estimated Data Size: 1777KB
SELECT '$' + CONVERT(varchar (10), UnitPrice) FROM Sales.SalesOrderDetail;
Actual Number of Rows: 121317
Estimated Row Size: 26B
Estimated Data Size: 3060KB
SELECT FORMAT(UnitPrice, 'c') FROM Sales.SalesOrderDetail;
Actual Number of Rows: 121317
Estimated Row Size: 4011B
Estimated Data Size: 464MB