Tuesday, August 30, 2011

Using the script task in Management Studio

Today I was taking a back of a database and for the past two days this has become my regular activity. So I thought there should be some kind of recording option (like recording a macro in excel) so that I can just use the recorded action whenever I need to do the same task again and again.

So I tried to investigate and found this script button. So I thought I would investigate this. The following are the steps I followed to backup a database in the Management Studio.


  • Right click the database that needs to be backed up.

  • Click on Task -- Backup

  • Choose the Backup options like how you choose normally.

  • Before clicking Ok click on the Script option at the top and choose the option that you want from the 4 options available as shown below.





This has generated a nice script as shown below.

BACKUP
DATABASE [TEST] TO

DISK

= N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\TEST20110830.bak' WITH FORMAT, INIT, MEDIANAME = N'TEST', NAME = N'TEST-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO


This script can be used to do the same task again and again and also may be you can schedule this to be processed at a certain time every day.



No comments:

Free Power BI Classes for Week 7 (Last)

Just completed the last class of the F ree  P ower BI  classes of this series.  Today we have covered Adding a canvas background Adding Imag...