0

rather new with regards to writing batch files. A quick background... we run a batch file that stopped SQL, copied file from server to local computer, extracted with 7zip and then started SQL. We recently started upgrading to windows 7 and the batch no longer works because admin privileges are needed for stopping SQL and only non-administrator mode can do the copy portion. The batch we used on xp is:

@echo On
ECHO Off
CLS

NET STOP MSSQL$namedsql

xcopy \server\folder1\folder2\file.7z
c:\folder\7za e P:\file.7z -op:\ -y

NET START MSSQL$namedsql

To make matters more confusing. I can run this whole batch in "administrator mode" on one computer but can't replicate this ability on any other computer.

Any possible solutions would be a tremendous help! Thank you!

  • Why do you need to stop the SQL Server service to copy a file? – Aaron Bertrand Feb 07 '14 at 17:03
  • The files that are extracted are .mdf & .ldf – SFloridaBadger Feb 07 '14 at 17:04
  • 1
    Take a backup. Stop stopping your services to copy the mdf & ldf files. This is not a proper backup (and what happens if the files get corrupted during the zip/copy process - good luck). – Aaron Bertrand Feb 07 '14 at 17:11
  • 2
    You know SQL Server has a fairly robust set of backup tools built in right? – Zane Feb 07 '14 at 17:17
  • possible duplicate of [What is a simple command line program or script to backup SQL server databases?](http://stackoverflow.com/questions/122690/what-is-a-simple-command-line-program-or-script-to-backup-sql-server-databases) – swasheck Feb 07 '14 at 17:19
  • not trying to backup SQL, in essence we have one "master" computer (if you will) that edits/updates the data daily. The remaining computers work using a copy of this. "master" computer uploads data.7z to server and remaining computers download data.7z. Again, trying to learn all of this on the fly so I'm not that familiar with these things. Regardless, I'll try your post swashcheck. – SFloridaBadger Feb 07 '14 at 17:27
  • The remaining computers should use a copy that is provided by taking a backup of the database, period. Not a "backup" of the mdf/ldf files. – Aaron Bertrand Feb 07 '14 at 17:29
  • Alright, I'll do that. I'll get back to you with any issues. Thanks for help. – SFloridaBadger Feb 07 '14 at 17:31
  • An alternative to shipping backups is [snapshot replication](http://technet.microsoft.com/en-us/library/ms151832.aspx). – Ralf Feb 07 '14 at 17:44

0 Answers0