microsoft / tigertoolbox

Toolbox repository for Tiger team
http://aka.ms/sqlserverteam
Other
1.48k stars 740 forks source link

DB_NAME(@dbID) returns Null #268

Open ChristopherElliott opened 2 years ago

ChristopherElliott commented 2 years ago

In my example sys.Databases lists my database_id as 6 but if I query DB_ID() it returns 5. The script uses database_id applied to DB_NAME and it returns null in my case. Googling is suggesting that this ID can't be relied upon and that the db name should be used instead.

ChristopherElliott commented 2 years ago

Proposed a fix that seems to work for my case: https://github.com/microsoft/tigertoolbox/pull/269