The query has a where clause AND c.column_id = 1;because of which this query always returns the first column of the table even if the partitioned column maybe 2nd or 3rd or nth.The correct query is:SELECT t.object_id AS Object_ID, t.name AS TableName, ic.column_id as PartitioningColumnID, col.COLUMN_NAME AS PartitioningColumnName FROM sys.tables AS tJOIN sys.indexes AS i ON t.object_id = i.object_idJOIN sys.columns AS c ON t.object_id = c.object_idJOIN sys.partition_schemes AS ps ON ps.
↧