This will return the level of fragmentation for every index in the current database:
SELECT b.NAME, [a].*
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL,
NULL, NULL, NULL) AS a
JOIN sys.indexes AS b ON a.object_id = b.object_id AND a.index_id = b.index_id
WHERE [a].index_id <> 0
ORDER BY avg_fragmentation_in_percent desc