<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d8211560\x26blogName\x3dTech+Tips,+Tricks+%26+Trivia\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://mvark.blogspot.com/search\x26blogLocale\x3den\x26v\x3d2\x26homepageUrl\x3dhttp://mvark.blogspot.com/\x26vt\x3d-5147029996388199615', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Tech Tips, Tricks & Trivia

by 'Anil' Radhakrishna
An architect's notes, experiments, discoveries and annotated bookmarks.

Search from over a hundred HOW TO articles, Tips and Tricks


HOW TO back up a database (schema and data) as a SQL Server script

Did you know, SQL Server 2008 Management Studio has an in-built option to generate a script that can help you restore an entire database alongwith the data? Compared to a .BAK file that can also be used to restore a database, a script lets you peek into the schema AND data (INSERT statements for rows within tables are automatically generated) before you restore it.

Unfortunately, this cool feature is hidden under layers of options and isn't easily discoverable unless a really discerning user points it out.


Steps to generate script:
1. Right click on a database name, choose Generate Scripts.. option under Tasks.. in the context menu
2. In the Generate and Publish Scripts wizard which appears choose the database object for which you want to generate a script
3. Under the Set Scripting Options, make sure to click on the Advanced button which reveals a bunch of more options.
4. In the new dialog box that opens up, scroll down to the last option in the General category and for Types of data to script, choose Schema and Data

If you need a migrate a database via a script for SQL Azure/SQL Database, you have to set the value for Script for the database engine type setting in the Advanced Scripting Options dialog box to SQL Azure Database


Related:
HOW TO view parameter values of a stored procedure through SQL Profiler
Why are these Visual Studio Settings not enabled by default?

Labels: ,

Tweet this | Google+ it | Share on FB

« Home | Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »

»

Post a Comment