BrentOzarULTD / SQL-Server-First-Responder-Kit

sp_Blitz, sp_BlitzCache, sp_BlitzFirst, sp_BlitzIndex, and other SQL Server scripts for health checks and performance tuning.
http://FirstResponderKit.org
Other
3.33k stars 991 forks source link

Database named ¯\_(?)_/¯ breaks sp_blitz #1756

Closed mabrahamsen closed 6 years ago

mabrahamsen commented 6 years ago

Version: 6.9 / 20180901

What is the current behavior? The database name ¯\(?)/¯ was popularized by Brent Ozar in this article: https://www.brentozar.com/archive/2017/10/log-wait-stats-table-sp_blitzfirst/

Running spblitz with a database named ¯\_(?)/¯ on your server breaks the sp_blitz script:


Msg 103, Level 15, State 4, Line 1 The identifier that starts with '¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(' is too long. Maximum length is 128. Msg 911, Level 16, State 1, Line 1 Database '¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(¯_(' does not exist. Make sure that the name is entered correctly.

Running with only default parameters.

What is the expected behavior? That the script runs successfully with all possible database names, whether they are hilarious or not.

Which versions of SQL Server and which OS are affected by this issue? Did this work in previous versions of our procedures? Running on SQL Server Enterprise Edition, 2016 SP2 CU2 / Windows Server 2016. Never tried on other versions.

BrentOzar commented 6 years ago

Hahaha, great catch! Sure, that'd be a fix we'd be totally okay with accepting. Here's the contributing guide on how to get started with the code:

https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/blob/master/CONTRIBUTING.md

If you decide you don't want to code it, no problem - just let us know and we can close the issue. (We'll close it if we don't hear back from you in a few days.)

mabrahamsen commented 6 years ago

Hi @BrentOzar,

The bug seems to be deeper than I can reach:

Ultimately this breaks: EXEC dbo.sp_MSforeachdb 'USE [?]; SELECT DB_NAME()';

While this works: EXEC dbo.sp_foreachdb 'USE [?]; SELECT DB_NAME()';

And I don't have the required insight to understand why you are using the MS version and shipping the other one, but I assume it is hardly accidental.

BrentOzar commented 6 years ago

Yeah, it'll be quite a bit of work to add in the open source replacement for sp_MSforeachdb. I'd started down that road too and didn't have enough time myself either. No worries - I'll close it then. Thanks anyway for reporting it!