Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 600645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:37:41+00:00 2026-05-13T16:37:41+00:00

With some slower machines that our application runs on (which is in the windows

  • 0

With some slower machines that our application runs on (which is in the windows startup folder), when the machine is Rebooted and autologged on, the SQL Server service is still in a starting up state when my application is launched. (SqlServer 2005)

What I’ve done to counter this is to Check the Service state (MSSQL$idealsql) and wait until the service is Running.

Public Function isServiceRunning() As Boolean
    Dim theServices() As System.ServiceProcess.ServiceController
    Dim theservice As System.ServiceProcess.ServiceController
    theServices = System.ServiceProcess.ServiceController.GetServices
    Dim running As Boolean

    For Each theservice In theServices
        If String.Equals(theservice.ServiceName, mServiceName, StringComparison.OrdinalIgnoreCase) Then
            running = (theservice.Status = ServiceProcess.ServiceControllerStatus.Running)
            Exit For
        End If
    Next
    Return running
End Function

This is returning the correct result once the service comes online, but SQLServer takes a little while before it is fully operational after the service has been started.

Update
This process is only used on application startup.
PseudoCode.
Check Service running (this process)
Check Database exists
false -> create database
true -> perform any updates required to structures etc
Continue into main program execution
End Update

I then need to check for the presence of our Database (that gets dynamically created if it’s not present), which I do via looking as sysdatabases, and finding if our database is there, but once again, it takes a little bit before all the databases are actually brought online.

I also found some additional code to check for the creation of the TempDB and get the date that it was created to determine when the service came online.

SELECT crdate AS StartTime FROM sys.sysdatabases WHERE name = 'tempdb'

According to the EventVwr, TempDB is the First Database brought online.

Is there a proper way to determine that SQLServer is fully online, and all databases have been started up?

Whilst the code shown is VB.Net i’m not too concerned with the language, moreso just the proper way to determine if the Database Server is fully online.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:37:41+00:00Added an answer on May 13, 2026 at 4:37 pm

    On a separate thread in your application, poll a table in your database (every 10 seconds say) with a low I/O query such as

    SELECT 1 FROM Some Table
    

    wrapped in ‘appropriate’ exception handling.

    Based on the result of that select (1 or NULL), raise your custom .NET events DBOnline and DBOffline respectively.

    Another approach using DMV’s (for SQL Server 2005 onwards) is discussed in this article: How to tell when the SQL Server service was started

    USE master
    GO 
    
    SELECT TOP 1        
        sample_ms AS Millisecond_Since_Start
    FROM        
        sys.dm_io_virtual_file_stats(DB_ID(), NULL)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since some time, my Delphi debugger became much slower than I was used to
Some web applications, like Google Docs, store data generated by the users. Data that
Some e-Marketing tools claim to choose which web page to display based on where
Some files in our repository are individual to each developer. For example some developers
I have a script that appends some rows to a table. One of the
i have a input tag which is non editable, but some times i need
This SELECT * FROM SOME_TABLE WHERE SOME_FIELD LIKE '%some_value%'; is slower than this SELECT
Some WPF controls (like the Button ) seem to happily consume all the available
Some API returns me XmlCursor pointing on root of XML Document. I need to
Some things look strange to me: What is the distinction between 0.0.0.0, 127.0.0.1, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.