Table Column Width

Just sharing a simple block of code to find the width of a row in a given table based on DDL used to create the table.  This is especially helpful if you are looking to take a table to In-Memory with a row size limitation of 8,000. Just used this for one of my customers this morning. Thought I would share my code for others to use.

select  sys.objects.[name] as TableName, 
           sys.objects.[object_id] as SQLObjectId, 
           count(sys.columns.[name]) As ColumnCount, 
           sum(sys.columns.max_length) As MaxLength
 from  sys.objects so
 inner join sys.columns sc
on so.object_id = sc.object_id
 where  sys.objects.[name] = INSERT TABLE NAME HERE
 group by  sys.objects.[name],