Baran Topal

Baran Topal


October 2024
M T W T F S S
« Feb    
 123456
78910111213
14151617181920
21222324252627
28293031  

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