Using dm_db_index_physical_stats
returns size and fragmentation information for the data and indexes of the specified table or view in SQL Server.
USE master;
GO
-- If Student.Name does not exist in the database, the function returns NULL.
-- If NULL is specified as an OBJECT_ID, all objects in the database are returned.
SELECT * FROM sys.dm_db_index_physical_stats
(DB_ID(N'AdventureWorks'), OBJECT_ID(N'Student.Name'), NULL, NULL , 'DETAILED');