IT tutorials
 
Technology
 

SQL Server 2012 : SQL Azure (part 3) - Migrating Data into SQL Azure

8/10/2013 6:13:42 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

4. Migrating Data into SQL Azure

There are many ways to get data into a SQL Azure database. You could run a script that contains a bunch of INSERT statements or explore some other ways, including these:

  • The bulk copy utility (BCP.exe): BCP is a command-line tool that has been around for a long time. Out of the box, it can upload data to a SQL Azure database.
  • SQL Server Integration Services (SSIS): SSSIS is a powerful tool for creating simple and complex dataflows. To SSIS SQL Azure is just another datasource. Keep in mind that, since OLE DB is not supported with SQL Azure, to use SSIS, you will have to use the ADO.NET library.
  • SQL Azure Migration wizard: CodePlex is an open source community that provides free tools to the public based on the Microsoft platform. One of the projects on CodePlex is the SQL Azure Migration Wizard. This wizard will help you migrate SQL Server 2005/2008 databases to SQL Azure. Not only will the wizard move the database, it has the ability to analyze trace files against Azure. This is very important for application compatibility testing.


One of my favorite databases is pubs. It’s still available bundled with Northwind and available as a free download at http://archive.msdn.microsoft.com/northwind. After downloading this zip file, simply connect to a local SQL Server instance and run the INSTPUBS.SQL script against your server, and you will have pubs and party like its 1999 all over again.

To get pubs in SQL Azure, we could have executed the script directly against our SQL Azure database, but we would need to make a slight modification to the script to remove the USE statements. Changing database contexts via an existing connection to SQL Azure is not something you can do. You would need to break the connection and reconnect to the other database to perform this action in SQL Azure. For purposes of demonstration, let’s assume the pubs database is installed in an on-premise SQL Server. When we launch SQLAzureMW.exe, we are presented with the wizard screen shown in Figure 8.

images

Figure 8. SQLAzureMW Select Process page

To migrate our PUBS database, click the SQL Database button, and click Next. At this point, we will be asked to connect to the source SQL Server that has the database we want to migrate. Provide the necessary connection information, and select “pubs” from the “Select source” page in the wizard. The next page will allow us to select which objects we want to migrate over. By default, this wizard will migrate all database objects including stored procedures, tables, user defined data types, and views. After this page, the wizard will confirm that you are ready to start generating the SQL Script. While the wizard is generating the script, you will see the status of the migration. This is the first step in the migration, and the wizard is essentially scripting the objects and using BCP.exe to push out the data into a file on the local directory. The Results Summary page is displayed in Figure 9.

images

Figure 9. Results Summary page for the first step in migration

Next, the wizard will ask you for the location of the SQL Azure database. Remember that “User name” in this case is not just the administrative user name we defined but includes “@servername” at the end of the username, as shown in Figure 10.

images

Figure 10. Connection dialog

After connecting to the SQL Azure server, you will be asked to which database to add pubs. Since we do not have pubs, we can click the Create Database button on the Setup Target Server Connection panel and create a new database called pubs. The next page will execute the script and BCP of the original data against the new SQL Azure database. Results of this are shown in Figure 11.

images

Figure 11. Target Server Response dialog

Now, we have a copy of pubs living in our SQL Azure database!

5. Understanding SQL Azure specific views

A few system views are only available on a SQL Azure database. If you connect to your SQL Azure Server and enumerate the system views within the master database, you will see these. You can notice these special SQL Azure–only ones by a small lock on the bottom right side of the view icon.

To return information about the bandwidth used by each database, we can use the sys.bandwidth_usage view. When we copy the pubs database to SQL Azure, we see exactly how much bandwidth was consumed since that operation. This view returns two rows for every database with one row showing data ingress and the other showing data egress. The results for a SELECT * FROM sys.bandwidth_usage is shown in Table 1.

images

The quantity field is in kilobytes (KB).

The sys.database_usage returns one row for each day of your subscription. The view returns the type of database (i.e., business or web) and the maximum number of databases of that SKU type that existed for that day. This view is useful to give you a guesstimate of the cost per day of the SQL Azure database.

The sys.firewall_rules view returns the list of firewall rules associated with the SQL Azure database. 

The sys.dm_db_objects_impacted_on_version_change view is a database-scoped view that provides early warning for objects that will be impacted by version upgrades. Version upgrades happen, and with SQL Azure, you need to stay current. Even though Microsoft does everything possible to remain backward compatible, there is some chance that things may break if not tested.

6. Backing Up and Restoring Data with SQL Azure

At the time of this writing there is no way to easily backup and restore your database within SQL Azure. You may be curious as to why such a fundamental maintenance task is missing from the standard capabilities of SQL Azure and the answer lies in the fact that a SQL Azure database inherently is highly available. Multiple copies of your database are created automatically as soon as you create the database. These multiple copies protect you from loss of the entire database. Server failures and failover happen automatically for SQL Azure databases and require no interaction or configuration on your part.

However, the story is still incomplete. What if someone calls you and says, “I accidently dropped a table can you restore a backup”? This is where there is no good answer as of yet. Your database as a whole is protected, but there is no good way to restore a single object such as an inadvertently dropped table.

Right now, you can use SSIS or an SQLCMD script to automate the data creation or regeneration. You may also look into creating a database copy. Of course, you would need to make a copy before this disaster happens. To create a database copy, simple execute the following command: CREATE DATABASE Pub2 AS COPY OF Pubs. Note that this will create a separate database of the same size as your original database. If you are counting your pennies, maintaining a separate database may add up in cost and will certainly add up in storage space if your databases are large.

There is system view called sys.dm_database_copies. This view will show information on the status of the copy operation. For relatively small databases, there won’t be a lot of useful information here, because the copy would happen so quickly the percentage_complete data would be meaningless. If the database failed to copy, the error_state column would reflect this.

7. Storing More Than Relational Data

The first effort with SQL Azure is to develop a highly scalable and robust relational database engine that can work with your Windows Azure applications and with on-premise data. Microsoft is not stopping at relational data. At the time of this writing, the SQL Azure Reporting feature is in Community Technology Preview (otherwise known as beta release). The first iteration of SQL Azure Reporting Services will include the ability to create and execute reports based off of data stored in Windows Azure or a SQL Azure database. Although the first version won’t be at feature parity with the on-premise SQL Server Reporting Services, it’s a step in the business intelligence direction. Although there is no official word on details regarding Microsoft’s story for SQL Server Analysis Services in the cloud, you can bet there is something in the works.

 
Others
 
- SQL Server 2012 : SQL Azure (part 2) - Managing a SQL Azure Database
- SQL Server 2012 : SQL Azure (part 1)
- SQL Server 2012 : Cloud Computing for the DBA - Cloud Service Models, Windows Azure
- Windows 7 : Managing Programs and Processes - Monitoring Performance with Task Manager, Networking and Users Tabs
- Windows 7 : Managing Programs and Processes - Peeking at Resource Usage, Managing Processes with Task Manager
- Windows 7 : Managing Programs and Processes - Not Responding? Task Manager to the Rescue
- Windows 7 : Managing Programs and Processes - Getting to Know Task Manager, Choosing Task Manager Views
- Windows 7 : Troubleshooting Software Problems (part 2) - Editing the Registry
- Windows 7 : Troubleshooting Software Problems (part 1)
- Windows Server 2012 Overview : Boot Configuration (part 5) - Managing the Boot Configuration Data store and its entries - Changing the operating system display order
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us