After our customers have installed CU25 there is a problem with the stored procedure sp_pkeys.
It may now return the wrong order if a primary key has multiple columns.
The crucial part is how KEY_SEQ is determined.
It would work correctly if the second variant would be used (CU24 or 2019).
Alternatively even the first variant would work if the sub-select would be done like this:
SELECT convert(smallint, key_ordinal) FROM sys.index_columns WHERE object_id = @table_id AND index_id = i.index_id and column_id = c.column_id
So key_ordinal instead index_column_id needs to be used.
The release notes mention a change to sp_pkeys. See https://support.microsoft.com/en-us/topic/kb5003830-cumulative-update-25-for-sql-server-2017-357b80dc-43b5-447c-b544-7503eee189e9#bkmk_13975159.
However as it is a system stored procedure it seemingly is not possible to change it.
At least not without very critical and unadvised steps.
Are there any alternatives than downgrading or waiting for a fix?
Edit: Just tested CU26. There is no change regarding the stored procedure.