Is there a way?

  • If manually did a sql backup (example, right clicking on the database name, Tasks, Backup) is there any way to capture this so I can either create a sql script or have it capture it for me? I don't know how to look under the covers of the gui to see what this process is doing.... I just want to be able to replicate this exact process, but with a script that I can automate or run automatically.

    Any suggestions for a newbie?

    Thanks!

  • dwayne.hofstetter (8/14/2013)


    If manually did a sql backup (example, right clicking on the database name, Tasks, Backup) is there any way to capture this so I can either create a sql script or have it capture it for me? I don't know how to look under the covers of the gui to see what this process is doing.... I just want to be able to replicate this exact process, but with a script that I can automate or run automatically.

    Any suggestions for a newbie?

    Thanks!

    You can always run profiler to track the sql statements that are being run. But in this case it is pretty straight forward because it is just a backup you want to execute.

    http://technet.microsoft.com/en-us/library/ms186865.aspx

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • In Management Studio:

    Right click on the database -> Tasks -> Backup...

    Make your choices in the Back Up Database dialog box

    Instead of clicking OK to start the back up, click in the Script button on the top. This generates a script in a new query windows and the Back Up Database dialog box is still active.

    If you click on the little triangle it gives you several choices to generate a script. The default action is: Script Action to New Query Window.

  • SQL Surfer '66 (8/15/2013)


    Instead of clicking OK to start the back up, click in the Script button on the top. This generates a script in a new query windows ...

    The option to script your actions is available on many places within SSMS. Many times it's also possible (for instance on a stored procedure) to right-click on an object and choose the "script as" option.

    Great way to learn about T-SQL and see what the GUI is doing!

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
  • One of those instances where I wish we could vote on answers. SQL Surfer has nailed it. When you're creating that backup in the GUI, just generate the script.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • This is a great way to learn what SQL the GUI is generating and firing, but consider taking it to the next step and checking out the commands on MSDN. That way you can not only learn the command, but a lot of the options available. This leads to a real understanding of the commands and you'll have it in your toolbox for later.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply