moving data into and out of sql azure using ssis · web viewmoving data into and out of sql azure...

22
Demo Script Moving Data Into and Out Of SQL Azure using SSIS Lab version: 1.0.0 Last updated: 4/14/2022

Upload: others

Post on 28-Mar-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

Demo ScriptMoving Data Into and Out Of SQL Azure using SSISLab version: 1.0.0

Last updated: 5/18/2023

Page 2: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

CONTENTS

OVERVIEW................................................................................................................................................. 3Key Messages......................................................................................................................................... 3

Key Technologies.................................................................................................................................... 3

Time Estimates........................................................................................................................................ 4

SETUP AND CONFIGURATION................................................................................................................. 4Task 1 – Running the Dependency Checker.........................................................................................4

Task 2 – Ensuring that the HolTestDB and HoLTestUser are created and configured.........................5

Task 3 – Ensuring that the AdventureWorksLT2008 Database is attached to the local SQL Server.....5

DEMO FLOW.............................................................................................................................................. 5

OPENING STATEMENT............................................................................................................................. 6

STEP-BY-STEP WALKTHROUGH.............................................................................................................6Delete Existing Data................................................................................................................................ 7

Create Data Flow and Map Unsupported Data Types...........................................................................11

SUMMARY................................................................................................................................................ 21

Page 3: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

Overview

This document provides setup documentation, step-by-step instructions, and a written script for showing a demo of SQL Azure. This document can also serve as a tutorial or walkthrough of the technology. In this demo, you will look at how to move data between a SQL Azure Database and an on premise SQL Server Database using SQL Server Integration Services. For additional demos of the Windows Azure platform, please visit http://www.azure.com.

Note: In order to run through this demo, you must have a SQL Azure account. For more information on how to purchase an account, visit the SQL Azure Portal at http://www.microsoft.com/windowsazure/sqlazure/.

Key Messages

1. SQL Azure supports the use of SQL Server Integration Services

2. SQL Server Integration Services is an ideal technology to move data into and out of SQL Azure.

Key Technologies

This demo uses the following technologies:

1. SQL Azure

2. SQL Server 2008 R2 Management Studio

3. SQL Server Business Intelligence Development Studio

4. SQL Server Integration Services

Page 4: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

Time Estimates

Estimated time for setting up and configuring the demo: 1 min

Estimated time to complete the demo: 10 min

Setup and Configuration

The setup and configuration for this demo involves the following tasks:

Run the dependency checker

Ensure that the HolTestDB and HoLTestUser are created and configured

Ensure that the AdventureWorksLT2008 Database is attached to the local SQL Server

Task 1 – Running the Dependency Checker

This demo does not have any advanced configuration requirements. You simply need to have the prerequisites installed and have an account for SQL Azure. For more information on how to purchase an account, visit the SQL Azure Portal at http://www.microsoft.com/windowsazure/sqlazure/.

The following steps describe how to run the Dependency Checker utility included with the demo to verify that you have the prerequisite components. You can skip this exercise if you are confident that the prerequisites are properly installed and configured.

1. Open a Windows Explorer window and browse to the demo’s Source\Script folder.

2. Double-click the Dependencies.dep file in this folder to launch the Dependency Checker tool and install any missing prerequisites.

3. If the User Account Control dialog is shown, confirm the action to proceed.

Page 5: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

Note: This process may require elevation. The .dep extension is associated with the Dependency Checker tool during its installation. For additional information about the setup procedure and how to install the Dependency Checker tool, refer to the Setup.docx document in the Assets folder of the training kit.

Note: This lab requires SQL Server Integration Services, which can be downloaded and installed as part of the SQL Server 2008 Trial or Developer Editions.

Task 2 – Ensuring that the HolTestDB and HoLTestUser are created and configured

You should ensure that you have followed the steps in the Demo scripts for 'Connecting to SQL Azure' and ' Managing Logins and Security in SQL Azure'. Specifically you need to have created the HoLTestDB database and HolTestUser login and user account and you must have granted the role db_owner to the HoLTestUser login.

Task 3 – Ensuring that the AdventureWorksLT2008 Database is attached to the local SQL Server

Ensure that you have attached the AdventureWorksLT2008 database to your local SQL Server before beginning. This can be found here: http://www.codeplex.com/MSFTDBProdSamples

You should download and execute the appropriate SQL2008.AdventureWorks_all_Databases.<ProcessorArchitecture>.msi for your processor architecture- x86, x64 or ia64.

Demo Flow

The step-by-step guide in this document follows the following demo flow/outline:

Page 6: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

Figure 1Demo Flow

Opening Statement

Many usage scenarios for SQL Azure will require moving data into and out of SQL Azure from on premise systems. SQL Server Integration Services (SSIS) provides an ideal tool for moving data into and out of SQL Azure. In this demo, we will look at how to create an SSIS package to move data from the cloud into an on-premise database.

Step-by-Step Walkthrough

This demo is composed of the following segments:

1. Delete Existing Data

2. Create Data Flow and Map Unsupported Data Types

Page 7: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

Delete Existing Data

In this first segment, we will create our SSIS package and delete the existing data from the on-premise database.

Action Script Screenshot

1. Open SQL Server Business Intelligence Development Studio. Start > All Programs > SQL Server 2008 > SQL Server Business Intelligence Development Studio

In this demo, we’ll be using SSIS to move Sales information from the cloud into our on premise copy of the Adventure Works database.

2. Open the New Project dialog. File > New > Project.

3. Select Business Intelligence Projects from the Project types list.

4. Select Integration Services Project from the Templates.

5. Name: CloudSalesImport6. Click OK

7. Ensure that Package.dtsx is open.

We need to create a new SQL Server Integration Services project.

8. Drag and drop the Execute T-SQL Statement Task from the Toolbox onto the Designer.

9. Click the Task to select.

10. Press F2 to rename the task to “Clear Sales Order Details”.

We’ll start with a task to clear out the existing data in our Sales table.

Page 8: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

11. Right click the Task and select Edit.12. Go to SQLStatement option.13. Type the statement

“DELETE FROM SalesLT.SalesOrderDetail”

14. Click OK.

We’re executing a simple SQL statement against the Database on my notebook/desktop/presentation machine.

The statement is going to delete all the rows from the SalesOrderDetail table

Page 9: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

15. Go to Connection.

16. Select the “New connection” option to create a new Connection.

17. Click New...

We need to create a new connection to our local copy of the Adventure Works LT database.

Page 10: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

18. Complete the connection details for the local database.

19. Server name: localhost

20. Authentication: Integrated.

21. Database name: AdventureWorksLT2008

22. Click OK.

Working on premise, we can use Windows authentication to connect to the server on localhost.

We need to set the database that is connected to Adventure Works.

23. Click OK to save the Connection.24. Click OK to save the Task.

Page 11: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

25. Drag another Execute T-SQL Task onto the package designer.

26. Name this “Clear Sales Order Headers”.

27. Link the original task to the new task by clicking and dragging the green arrow.

Now we’ll add another task to clear out the sales order details table.

For brevity we won’t actually be copying across the details data, but, we need to clear both tables for the sake of referential integrity

28. Edit the new Task to use the T-SQL Statement“DELETE FROM SalesLT.SalesOrderHeader”

29. Ensure that the Connection is set to localhost.AdventureWorksLT2008.

30. Click OK.

Create Data Flow and Map Unsupported Data Types

In this segment, we will create the dataflow to copy data from SQL Azure to SQL Server running locally.

Action Script Screenshot

Page 12: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

31. Drag on a Data Flow Task to the package designer.

32. Link the “Clear Sales Order Headers” task with the dataflow task by selecting the “Clear Sales Order Headers” task and dragging the green arrow to the “Data Flow Task”.

33. Rename the data flow task to “Copy across headers”.

Now we’ll use DataFlow tasks to pull the data from SQL Azure down to our local database.

To maintain referential integrity we’ll copy across the headers first..

34. Edit the “Copy across headers” task.The Data Flow tab should now be displayed.

35. Drag on an ADO NET Source from the Toolbox

36. Rename the source to “Cloud Sales Headers”

37. Right Click on “Cloud Sales Headers” and click Edit

To connect to SQL Azure we need to use an ADO.NET source so we’ll drag one of those out.

Page 13: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

38. In the ADO.NET Source Editor click New …

Page 14: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

39. Click New… again

Page 15: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

40. Fill in the connection properties with the login to the Cloud SQL Azure database and type in HolTestDB as the database.

You should use the HolTestUser login that was created in earlier demos.

We’ll login as the HoLTestUser account that we created earlier.

We need to type the database name; the Database name drop down will not list the databases on our SQL Azure Server in the current CTP.

41. Click Test Connection to ensure that the connection is appropriately setup.

42. Click the OK button to close the Test Connection dialog.

43. Click the OK button to save the Connection.

It is worth testing the connection now just to ensure we’ve got everything configured correctly.

Page 16: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

44. Select the SQL Azure Connection and click the OK button to select the connection for the ADO NET source.

45. Choose Table or view as the data access mode.

46. Select the SalesLT.SalesOrderHeader table.

47. Click the OK button.

We’re pulling the data from the SalesOrderHeader table.

48. Drag an OLE DB Destination out of the toolbox.

49. Name this “Local Sales Header”.50. Link between “Cloud Sales Headers”

and “Local Sales Headers”.51. Edit the new destination.

We can use an OLE DB destination for our on premise SQL Server database.

Page 17: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

52. Select localhost.AdventureWorksLT2008 as OLD DB connection manager.

53. Set the Data access mode to Table or View – fast load.

54. Name of the table: SalesOrderHeader55. Check Keep identity.

We’ll set the Keep identity option. This enables identity insert on the table and ensures that our Header rows and detail rows remain appropriately related once we’ve transferred them.

Page 18: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

56. Click the Mappings section and note that there are default mappings.

57. Click OK to close the dialog.

We can just leave the default mappings for the time being because our SQL Azure and SQL Server databases have the same schema.

58. Take a look at the Error List.Note that there are currently errors in our package.

There are some errors with our package. Relating to the conversion of our String Data Type

59. Drag on a Data Conversion transformation.

60. Delete the existing link between Source (Cloud Sales Headers) and Destination (Local Sales Headers).

61. Connect the Source to the Conversion transformation.

62. Right click and Edit the Conversion.

We’ll use a data conversion transformation to resolve this issue

Page 19: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

63. Add an input column to the list by checking the checkbox beside the CreditCardApproval.

64. Change the output alias to NewCreditCardApproval.

65. Change the Data Type to string [DT_STR].

66. Click OK to close the dialog.

We’ll create a mapping for the CreditCardApproval column.

SQL Azure uses Unicode strings but our on-premise database does not. We’re converting to a non-unicode string that we can then insert into the local database.

67. Link the “Data Conversion” transformation to the “Local Sales Headers” destination.

Now let’s wire our conversion up to our destination

68. Edit the mappings for the destination.69. Delete the link between the two

CreditCardApproval columns.70. Link up the new column that comes

from the Conversion.71. Click OK to close the dialog.

We’ll remap our converted column to the appropriate destination column.

Page 20: Moving Data Into and Out Of SQL Azure using SSIS · Web viewMoving Data Into and Out Of SQL Azure using SSIS Lab version:1.0.0 Last updated:8/5/2010 Contents Overview3 Key Messages3

72. Click on the control flow tab to view the control flow again.

73. Press F5 to start debugging the package.

Now let’s test our package

74. The three steps in the package flow will turn green as the package runs.

We’ll see each step of the package executing as the local database is cleared of data and then the Order headers are copied from SQL Azure into the local database.

Summary

In this demo we copied data from our SQL Azure database down into a local database using SQL Server Integration Services.