You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
max_key_ordinal --get the max ordinal number for complete list of columns
AS
(
SELECT
object_id
, parent_object_id
, max_ordinal_value =MAX(key_ordinal)
FROM column_names
GROUP BY
object_id
, parent_object_id
)
,
primary_key_columns(object_id, parent_object_id, PrimaryKeyName, ColumnNames, SchemaName, TableName, key_ordinal, key_number, clustered_desc) -- recursive query to get all the columns in a comma separated list