How to fix Error 2754 on Windows Server 2025 / Windows 11

Troubleshooting Guide: SQL Server Error 2754

Why This Error Happens

This error occurs when a user attempts to execute a RAISERROR statement or create a custom error message with a severity level greater than 18 without having the appropriate permissions. SQL Server restricts severity levels 19-25 to members of the sysadmin fixed server role because these levels are reserved for serious system-level or fatal errors. The system enforces this restriction to prevent non-privileged users from triggering alerts that mimic critical database engine failures or from inadvertently taking connections offline.

Step-by-Step Resolution Guide

Step 1: Verify the Current User’s Role Membership

  • Open SQL Server Management Studio (SSMS) and connect to the instance using an account with administrative access.
  • Run the following query to check if the affected login is part of the sysadmin role:
  SELECT IS_SRVROLEMEMBER('sysadmin', 'YourLoginName');
  • A return value of 0 confirms the user lacks the necessary permissions, which is the root cause of Error 2754.

Step 2: Adjust the Severity Level in the Script (Recommended Fix)

  • If elevating user privileges is not appropriate for your security policy, modify the application code or T-SQL script instead.
  • Change the severity level in your RAISERROR statement to 18 or lower, as this range does not require special permissions.
  RAISERROR('Custom error message', 16, 1);
  • Save and redeploy the script to the application server running on Windows Server 2025.

Step 3: Grant Sysadmin Privileges (If Elevated Severity is Mandatory)

  • If the business logic strictly requires a severity level between 19 and 25 (e.g., for triggering a Windows Event Log alert), the executing login must be added to the sysadmin role.
  • Execute the following command via SSMS or sqlcmd on the Windows 11/Server 2025 host:
  ALTER SERVER ROLE sysadmin ADD MEMBER [DOMAIN\Username];
  • Restart the SQL Server Agent service if the job execution context needs to refresh its cached permissions.

Step 4: Use WITH LOG for High-Severity System Alerts

  • If the goal is to log the error without needing to halt the system via high severity, use the WITH LOG option combined with a lower severity level.
  • This writes the event to the SQL Server error log and the Windows Application Event Log without requiring sysadmin escalation for the specific severity level (provided the level remains at 18 or below).

Alternative or Verification Steps

  • Verify the Fix: Re-run the specific stored procedure or script that triggered Error 2754. If the severity level was lowered, the script should execute without throwing a permission error.
  • Check Event Viewer: On Windows Server 2025, open the Event Viewer and navigate to Windows Logs > Application to confirm that the RAISERROR event was logged correctly under the MSSQLSERVER source without triggering a new permissions exception.