Simple CREATE, BACKUP & DROP DATABASE

SSMS is very useful for all SQL Server maniacs to help doing something, like query execution or database administration by GUI. Several of them are create, backup and drop database. I really curious how to create, backup or drop database using query, so, these all what I got from http://technet.microsoft.com/en-us/library/ms186865.aspx.

[code language=”sql”]
— sample create database with default or automatic configuration
CREATE DATABASE aaa

— backup file database
BACKUP DATABASE [aaa] TO DISK = N’C:program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVER2008MSSQLBackupaaa.bak’
WITH NOFORMAT, — Specifies that the backup operation preserves the existing media header and backup sets on the media volumes used for this backup operation. This is the default behavior.
NOINIT, — Indicates that the backup set is appended to the specified media set, preserving existing backup sets. If a media password is defined for the media set, the password must be supplied. NOINIT is the default.
NAME = N’aaa-Full Database Log Backup’,
SKIP, — Disables the checking of backup set expiration and name that is usually performed by the BACKUP statement to prevent overwrites of backup sets.
NOREWIND, — Specifies that SQL Server will keep the tape open after the backup operation.
NOUNLOAD, — Specifies that after the BACKUP operation the tape will remain loaded on the tape drive.
STATS = 10 — Displays a message each time another percentage completes, and is used to gauge progress. If percentage is omitted, SQL Server displays a message after each 10 percent is completed.

— drop database
DROP DATABASE aaa
[/code]

I hope this help.

Marifnst, 2013-09-11

Leave a Reply

Your email address will not be published. Required fields are marked *

Afiseaza emoticoanele Locco.Ro