# A question for you DBA's

**URL:** https://boards.straightdope.com/t/a-question-for-you-dbas/9071
**Category:** Factual Questions
**Created:** [March 23, 2000, 7:38pm UTC](https://boards.straightdope.com/t/a-question-for-you-dbas/9071 "2000-03-23T19:38:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![KarmaComa](https://avatars.discourse-cdn.com/v4/letter/k/e36b37/32.png) [@KarmaComa](https://boards.straightdope.com/u/KarmaComa)
#### Post date: [March 23, 2000, 7:38pm UTC](https://boards.straightdope.com/t/a-question-for-you-dbas/9071/1 "2000-03-23T19:38:00Z")

</div>

OK what I need to do is shut down an SQL database, backup the database file, and restart the SQL database. (Oh no. that’s so hard). OK the hard part is doing it in an automated batch file. Does anyone know how?

Also, could I do a hot backup (i.e. back up the file without stopping the database)?

---

<div class="post-metadata">

### Author: ![SingleDad](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@SingleDad](https://boards.straightdope.com/u/SingleDad)
#### Post date: [March 23, 2000, 7:43pm UTC](https://boards.straightdope.com/t/a-question-for-you-dbas/9071/2 "2000-03-23T19:43:00Z")

</div>

It would probably help if you specified the environment and database server you’re using.

---

<div class="post-metadata">

### Author: ![Lord\_Derfel](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@Lord\_Derfel](https://boards.straightdope.com/u/Lord_Derfel)
#### Post date: [March 23, 2000, 8:18pm UTC](https://boards.straightdope.com/t/a-question-for-you-dbas/9071/3 "2000-03-23T20:18:00Z")

</div>

Assuming MS-SQL server 7 and NT, with root privileges, create a batch file with the following commands:

net stop “MSSQLServer”  
copy _database files_  
net start “MSSQLServer”

As for backing up without stopping the database, just use the SQL Backup wizard. Under “Management” select the “backup” icon. Right click on the window and choose: “New Backup Device” and write to a file/tape/whatever.

---

<div class="post-metadata">

### Author: ![KarmaComa](https://avatars.discourse-cdn.com/v4/letter/k/e36b37/32.png) [@KarmaComa](https://boards.straightdope.com/u/KarmaComa)
#### Post date: [March 23, 2000, 8:46pm UTC](https://boards.straightdope.com/t/a-question-for-you-dbas/9071/4 "2000-03-23T20:46:00Z")

</div>

Wow… excellent… it is MS-SQL 7 and NT. Many thanks.

---

<div class="post-metadata">

### Author: ![KarmaComa](https://avatars.discourse-cdn.com/v4/letter/k/e36b37/32.png) [@KarmaComa](https://boards.straightdope.com/u/KarmaComa)
#### Post date: [March 23, 2000, 8:50pm UTC](https://boards.straightdope.com/t/a-question-for-you-dbas/9071/5 "2000-03-23T20:50:00Z")

</div>

Wow… excellent… it is MS-SQL 7 and NT. Many thanks.
