A community member has associated this post with a similar question:
Querying table index stats not working

Only moderators can edit this content.

Synapse Dedicated pool index stats

Jani Hämäläinen 40 Reputation points
2024-06-14T08:39:27.7+00:00

I try to get the fragmentation of my indexes with code

SELECT IPS.Index_type_desc, 
      IPS.avg_fragmentation_in_percent, 
      IPS.avg_fragment_size_in_pages, 
      IPS.avg_page_space_used_in_percent, 
      IPS.record_count, 
      IPS.ghost_record_count,
      IPS.fragment_count, 
      IPS.avg_fragment_size_in_pages
   FROM sys.dm_db_index_physical_stats(DB_ID(),NULL, NULL, NULL , 'DETAILED') AS IPS

How ever this gives me error

Parse error at line: 9, column: 40: Incorrect syntax near 'DB_ID'

Why does this not work?

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,557 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,904 questions
{count} votes