To include the schema in the query to check statistics on a table in Azure SQL Server, you can modify the query as follows:
SELECT
SCHEMA_NAME(o.schema_id) AS SchemaName,
OBJECT_NAME(s.object_id) AS TableName,
s.name AS StatisticName,
STATS_DATE(s.object_id, s.stats_id) AS LastUpdated,
s.auto_created,
s.user_created,
s.no_recompute,
sp.last_updated AS SampleLastUpdated,
sp.rows AS Rows,
sp.modification_counter AS ModificationCounter
FROM
sys.stats AS s
JOIN
sys.objects AS o ON s.object_id = o.object_id
OUTER APPLY
sys.dm_db_stats_properties(s.object_id, s.stats_id) AS sp
WHERE
o.type = 'U' -- User-defined table
AND SCHEMA_NAME(o.schema_id) = 'YourSchemaName' -- Replace 'YourSchemaName' with the name of your schema
AND OBJECT_NAME(s.object_id) = 'YourTableName' -- Replace 'YourTableName' with the name of your table
ORDER BY
SCHEMA_NAME(o.schema_id), OBJECT_NAME(s.object_id), s.name;
The columns in the query provide information about the statistics of tables in an Azure SQL Server database. Here’s what each column represents:
SchemaName
: The name of the schema to which the table belongs.TableName
: The name of the table.StatisticName
: The name of the statistics object.LastUpdated
: The date and time when the statistics were last updated.auto_created
: Indicates whether the statistics were automatically created by SQL Server.user_created
: Indicates whether the statistics were manually created by a user.no_recompute
: Indicates whether statistics recomputation is disabled.SampleLastUpdated
: The date and time when the sample statistics were last updated.Rows
: The number of rows in the table.ModificationCounter
: Indicates the number of modifications made to the table since the statistics were last updated.