Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is MSSQL exception code for "SHUTDOWN is in progress. Login failed for user ''XXXX''. Only administrators may connect at this time."

I want to know the SQL Exception error code for the above exception. It occurs when there is an unexpected sql cluster service shutdown, and an application tries to access the server.

like image 474
user3710477 Avatar asked Dec 10 '14 12:12

user3710477


1 Answers

These are two separate messages: "SHUTDOWN is in progress" (code 6005) and "Login failed for user '%.*ls'. Only administrators may connect at this time.%.*ls" (code 18451). You can determine this by querying sys.messages:

select * from sys.messages 
where [text] like '%only administrators%' or [text] like 'SHUTDOWN is in progress%'
and language_id = 1033

Because "SHUTDOWN is in progress" has severity 10, it's merely informational and will not result in an exception. "Login failed" will, however (and the "SHUTDOWN" message will be incorporated into it).

Note that if your server has already shut down, or is in the process of shutting down and its network name is no longer accessible, you can get other errors during the connection attempt that aren't generated by the server. Looking for this error is not a reliable way of detecting a shutdown condition, and you probably shouldn't have special-case logic for it.

like image 180
Jeroen Mostert Avatar answered Jun 05 '23 23:06

Jeroen Mostert