sp_BlitzIndex v 4.5 (2016-11-15) 因整理错误而失败

Cla*_*ton 4 sql-server-2016 sp-blitzindex

发布此信息以防其他人遇到此问题...(修复如下)更新到 SQL 2016 SP1 后,我还更新到了 sp_Blitz procs 的最新版本。不幸的是,sp_BlitzIndex 现在在“收集计算列信息”中爆炸了。线 1586 附近的部分。

这是错误文本:

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.
Run Code Online (Sandbox Code Playgroud)

解决方案是在第 1599 行(提供的脚本文件中的第 1605 行)添加 COLLATE 语句:

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

Bre*_*zar 6

我们一直在这里一起解决这个错误:

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

原来问题是包含数据库。如果您有一个包含的数据库,sp_BlitzIndex 将失败。(我以前从未真正在野外看到过包含数据库,所以这有点令人惊讶 - 想知道它已经被破坏了多久。)