4

Posting this in case anyone else runs into this issue... (fix below) After updating to SQL 2016 SP1, I also updated to the latest version of the sp_Blitz procs. Unfortunately, sp_BlitzIndex now blows up in the 'Gathering Computed Column Info.' section around line 1586.

Here is the error text:

Gathering Computed Column Info.
Failure populating temp tables.
Msg 2787, Level 16, State 1, Procedure sp_BlitzIndex, Line 1620 [Batch Start Line 4]

Invalid format specification: 
    '%.%' THEN 1 ELSE 0 END AS is_function,
    'ALTER TABLE ' + QUOTENAME(s.name) + '.' + QUOTENAME(t.name) + 
    ' ADD ' + QUOTENAME(c.name) + ' AS ' + cc.definition  + 
    CASE WHEN is_persisted = 1 THEN ' PERSISTED' ELSE '' END + ';' AS [column_definition]
    FROM    [Production-db].sys.computed_columns AS cc
    JOIN    [Production-db].sys.columns AS c
    ON      cc.object_id = c.object_id
    AND cc.column_id = c.column_id
    JOIN    [Production-db].sys.tables AS t
    ON      t.object_id = cc.object_id
    JOIN    [Production-db].sys.schemas AS s
    ON      s.schema_id = t.schema_id
    OPTION (RECOMPILE);'.

Msg 50000, Level 16, State 1, Procedure sp_BlitzIndex, Line 1624 [Batch Start Line 4]

Production-db database failed to process. 
Cannot resolve collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_100_CI_AS_KS_WS_SC" in add operator occurring in SELECT statement column 11.

The solution was to add a COLLATE statement to line 1599 (line 1605 in the delivered script file):

CASE WHEN is_persisted = 1 THEN '' PERSISTED'' ELSE '''' END + '';'' collate SQL_Latin1_General_CP1_CI_AS AS [column_definition]

Philᵀᴹ
  • 31,952
  • 10
  • 86
  • 108
Clayton
  • 41
  • 1

1 Answers1

6

We've been working together on this error over here:

https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues/607

Turns out that the problem is contained databases. If you have a contained database, sp_BlitzIndex fails. (I've never actually seen a contained database in the wild before, so that's kinda amazing - wonder how long this has been broken.)

Brent Ozar
  • 43,325
  • 51
  • 233
  • 390