Monday, August 18, 2008

Here is a really nice simple way of seeing how big the data in your table/column is. I often use this for maintenance to see over time how much data is being entered into a column. If the database has been in use for a while and you see that the majority of the data being entered is smaller then the size of the column you can go back and change the varchar/char data columns. This will save you space and performance over the lifetime of your application.
SELECT
ColumnName, LEN(ColumnName) Length
FROM
dbo.EventLog
GROUP BY
ColumnName
ORDER BY
Length DESC