title: Database clients: how to wait for database activation after SQL Server restart?
body: <p>Service dependency is not enough to guarantee that database clients will find their SQL Server up and running after a system reboot.  They may be able to create a connection to the master database, but a specific database may still be in the process of opening (in the recovery mode) and connections to it will be refused for some initial period of time.</p>
  
  <p>The exact duration of the delay is highly variable and depends on factors such as number of databases on the system, recovery mode, LDF file size, or traffic prior to the reboot.</p>
  
  <p>The well known approach to dealing with the dependency on the client is sleeping and retrying.  However, this approach does not seem exactly clean or reliable, especially when the clients are diverse in terms of technology and ownership and when this race condition appears only very rarely.</p>
  
  <p>Is there any better way to synchronize the clients with the server start-up, ideally through keeping the SQL Server service in the "Starting" state until all databases have been either opened or marked suspect?</p>