I have a table where I want to get size of the number records based on byte In SQL Server:
            Asked
            
        
        
            Active
            
        
            Viewed 457 times
        
    0
            
            
         
    
    
        Brian Tompsett - 汤莱恩
        
- 5,753
- 72
- 57
- 129
 
    
    
        mojtaba khooshrou
        
- 11
- 5
1 Answers
0
            
            
        The only answer related to this question that I can suggest is this:
SELECT
    s.name AS SchemaName,
    t.name AS TableName,
    p.rows AS RowCounts,
    a.total_pages * 8 AS TotalSpaceKB,
    a.used_pages * 8 AS UsedSpaceKB,
    a.total_pages * 8 / p.rows AS eachRowTotalSpaceKB,
    a.used_pages * 8 / p.rows AS eachRowUsedSpaceKB,
    a.total_pages * 8 / p.rows * (select * from dbo.PictureTable where SchoolCode=1001) AS queryTotalSpaceKB,
    a.used_pages * 8 / p.rows * (select * from dbo.PictureTable where SchoolCode=1001) AS queryTotalSpaceKB
FROM 
    sys.tables t
INNER JOIN      
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN 
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN 
    sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN 
    sys.schemas s ON t.schema_id = s.schema_id
WHERE 
    s.name = 'dbo' AND
    t.name = 'PictureTable';
Edit
You can get length of your data in a field by using DATALENGTH like this:
SELECT SUM(DATALEGTH(PictureTable_ID)) + SUM(DATALEGTH(Groupcourses_ID)) +SUM(DATALEGTH(per_ID)) + SUM(DATALEGTH(School_ID)) + SUM(DATALEGTH(AcademicYear_ID)) + SUM(DATALEGTH(PictureTable_Description)) + SUM(DATALEGTH(SchoolCode)) As rowSizes
FROM PictureTable
WHERE (SchoolCode = 1001);
- 
                    Is All Weight table -- I Went Custom Number Records Weight In Table – mojtaba khooshrou Jan 17 '16 at 14:00
- 
                    If you want to know the data length of each row I add an edited info to my answer ;). – shA.t Jan 18 '16 at 05:08
- 
                    

 
     
    
--How Size table By Condications ==>select * from dbo.PictureTable where SchoolCode=1001<== – mojtaba khooshrou Jan 16 '16 at 09:32