SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Powershell Script for regular DBA activities

By Mayank Shukla,

Most of the time, the developers come to the DBA for some routine tasks like Sql Backups and restore for different development and testing environments. This requires DBA to manually perform these operations via SSMS. Sometimes the operation is straight forward, while most of the times we have to configure some advanced options for our operations.

This small powershell utility takes care of such operations and elegantly performs it via command shell without SSMS interaction.

Such utilities can be easily used by the developers in the team without making them approach to DBA for such tasks on various development or testing environments.

Please note, this tool supports below operations on the same Sql Server machine : 

1.      Backup a DB to a physical .bak file

2.      Restore a DB from a .bak file

3.      Restore a DB from a DB

4.      Create a new DB from existing DB

Below is the working of this utility explained:

(1)Creating a backup file for a database (Enter Option 1)

Enter the database name, whose backup you need, then it will give you a browse folder window to select the folder where the file should be saved

Select the folder and it’s done.

(2)Restore Database from .bak file (saved on disk) (Enter Option 2)

Enter the name of the DB, whose backup file you are using.

Enter the name of the Database, that you wish to restore. After which it gives you file dialog box to select the .bak file for restoring

And its done.

(3)Restore database from database  (Enter Option 3)

Just enter the source and the destination database

(4)Create a new database from existing database  (Enter Option 4)

Enter the name of the source database and the new database

Total article views: 1357 | Views in the last 30 days: 10
Related Articles

Restore option-During cutover

Restore option-During cutover


database backup and restore in sql server 2005

database backup and restore using java


Unable to restore backup

Unable to restore backup





Restore from Backup with Replicated Database

Restore from Backup with Replicated Database