sql-server-maintenance-solution icon indicating copy to clipboard operation
sql-server-maintenance-solution copied to clipboard

serverproperty('servername') output changed from 2019 RTM to CU18 and leads to backup error on case sensitive instances

Open MattOWall opened this issue 3 years ago • 1 comments

It seems that starting with CU18 (?) for SQL Server 2019 the output of 'select serverproperty('servername')' is not longer in UPPER.

In 15.0.2000.5 the servername returned is in UPPER characters where in 15.0.4261.1 it returns the servername as configured in the OS in lower and UPPER. In not case sensitive instances this is not a problem but in case sensitives it is.

In the stored procedure [dbo].[DatabaseBackup] the line 2266 returns an error because @@Servername is always in UPPER and the comparison matches. IF @@SERVERNAME <> CAST(SERVERPROPERTY('ServerName') AS nvarchar(max)) AND SERVERPROPERTY('IsHadrEnabled') = 1

if I add an UPPER() it works fine. IF @@SERVERNAME <> UPPER(CAST(SERVERPROPERTY('ServerName') AS nvarchar(max))) AND SERVERPROPERTY('IsHadrEnabled') = 1

Maybe I missed something, but that's what I experienced...

Cheers Matt

MattOWall avatar Nov 09 '22 13:11 MattOWall

I had a similar issue with Integrity checks. Same logic.

I changed mine to (covers both bases): IF UPPER(@@ServerName) <> UPPER(CAST(SERVERPROPERTY('ServerName') AS nvarchar(max))) AND SERVERPROPERTY('IsHadrEnabled') = 1

My @@servername was lower, and the SERVERPROPERTY servername was upper. Opposite of what you get.

Have logged a separate bug request, as it is in a different stored proc.

Steve

Pineapple-lumps avatar Feb 16 '23 03:02 Pineapple-lumps