Restarting SQL Server every night

  • Hello,

    I've got a question about restarting the MSSQLSERVER service in Windows. I need to do that every night. How could I achieve this goal?

    Thanks in advance

  • net stop mssqlserver

    net start mssqlserver

    and schedule it at windows level (at command).

  • Ok, I figured it out already, Actually it is:

    net stop sqlserveragent

    net stop mssqlserver

    net start mssqlserver

    net start sqlserveragent

    Otherwise it will not work automatically, and net stop will ask to stop the services that are dependent of mssqlserver.

    But thanks for your answer.

  • I am curious as to why you find it necessary to stop and start SQL Server every night?

    GaryA

     

  • Because the SQL Server process took over 120 mb from my system memory. At the location our customer is working, they have only a server available with 384 mb of memory. Besides SQL Server, another database server (don't know which one exactly) is running on that server.

  • We also restart the SQL every night (not only the SQL service, but the complete server).

    We saw a great performance increase after we decided to do this.

  • I think I know what the problem is. The program that uses the database on the SQL Server is build using data bound controls. They don't work always the way the programmer wants. With ADO (bound recordset), the database is reached and updated and so on. With large recordsets this could be the problem of using that much memory.

    Next project should never, never and never again be programmed with data bound controls!

  • You can set a limit on the amount of memory the server will use. In EM, right click server, Properties, Memory tab.

  • You can also kill all active threads flush caches to free up memory inside the SQL Server memory space. I would avoid stopping and starting SQL for one simple reason, tempdb gets rebuild every time you start and stop SQL. This will lead to disk fragmentation over the long run and hurt performance. tempdb will also have to grow every day as it is utilized. You are also flushing away any query plans that can help SQL run faster. I would also consider buying memory, it is cheap and is the best upgrade for the dollars spent. SQL is trying to take the memory it needs to perform as well as possible setting the memory down to a lower size will fix the issue of restarting but may lead to other performance issues down the road.

    Wes

  • I'm relatively new to SQL Server. What do you mean with 'kill all active threads flush caches to free up memory inside the SQL Server memory space'?

  • there are scripts here that will issue a kill command and that will remove any connections from users on the server then you can issue dbcc statements that will flush out the caches. That is documented in Books On Line.

     

    Wes

  • I only restart our SQL Server when it is absolutly needed. It may go a month or two before we restart and we rarely have any problems.

    Thanks,

    Bobby

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply