• Your error was actually fairly trivial: you hade overlooked that the tag looks like this:

    <Object Database="[bos_sommar]" Schema="[dbo]" Table="[currencies]" Index="[pk_cur]" IndexKind="Clustered" />

    That is, the index name is quoted in brackets.

    I changed the procedure, to have this line in the beginning:

    SELECT @IndexName = quotename(@IndexName)

    And then I removed two invocations of quotename that you had, and now I got output from the second query.

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]