I am creating a batch program which will stop the services of SQL Server and copy .mdf
and .ldf
files to a specified location.
This is my batch file:
net stop mssqlserver
xcopy /s "C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\test.mdf" "D:\backup"
xcopy /s "C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\test_log.ldf" "D:\backup"
net start mssqlserver
It is stopping SQL Server Agent, but not SQL Server itself, so it cannot copy the files.
Why is it not stopping the SQL Server service?
What do I need to do to stop the SQL Server service?
Thanks in advance