Baran Topal

Baran Topal


April 2024
M T W T F S S
« Feb    
1234567
891011121314
15161718192021
22232425262728
2930  

Categories


killing existing SQL server connection except the login started by current session

baranbaran

This is a handy one that I found while googling. Credits to the owner of the script.

These are the steps you need to follow:
1) Stop SQL Server instance
2) Start SQL Server instance in Single user mode
3) Run the Restore command
4) Stop SQL Server instance
5) Start SQL Server instance in Multi user mode


Net stop MSSQLSERVER
Net start MSSQLSERVER /m
sqlcmd -S ServerName\instanceName -E -Q "RESTORE DATABASE databasename FROM DISK='C:\Backup\databasename.bak'"
Net stop MSSQLSERVER
Net start MSSQLSERVER