moving data lesson 23. skills matrix moving data when populating tables by inserting data, you will...

19
Moving Data Moving Data Lesson 23

Upload: maia-score

Post on 16-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Moving DataMoving DataLesson 23

Page 2: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Skills MatrixSkills Matrix

Page 3: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Moving DataMoving Data

• When populating tables by inserting data, you will discover that data can come from various sources.

• One of these sources could be an application where you would use INSERT, UPDATE, and DELETE statements to populate and manipulate the data you store in a SQL Server database.

Page 4: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Import DataImport Data• You can import data using the following:

– BULK INSERT statements– The bcp utility– Data transformations using SSIS– The import/export wizard– Copy database wizard– Detaching/attaching databases– Backup/restore databases– Bulk insert XML data

Page 5: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

BULK INSERTBULK INSERT

• A BULK INSERT statement loads a data file into the database using a user-specified format, without forcing the execution of the constraints defined on the destination object.

Page 6: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

bcp Utilitybcp Utility• The bcp utility, a command-line tool, is

commonly used for importing and exporting data by performing bulk imports/exports of text data.

• The utility allows you to do the following:– You can bulk export data from a table to

a file.– You can bulk export data from a query to a

file.– You can bulk import data into SQL Server.– You can create format files.

Page 7: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

SSISSSIS• In SQL Server 2000 a commonly used tool to

import and export data was the SQL Server 2000 DTS Wizard.

• Starting with SQL Server 2005, SQL Server provides a new extract, transfer, and load (ETL) platform: SQL Server Integration Services (SSIS).

• With SSIS you have the ability to import and export data from heterogeneous sources to various destinations.

• The toolset provides you with extensive data transformations.

Page 8: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

SSISSSIS

Page 9: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Import and Export WizardImport and Export Wizard• The SQL Server Import and Export Wizard offers

the simplest method to create the Microsoft SQL Server Integration Services package that copies data from a source to a destination.

• The wizard can access a variety of data sources, including:– SQL Server– Flat files– Access– Excel– Other OLE DB providers

Page 10: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Copying DatabasesCopying Databases

• One of the handiest tools in the SQL Server arsenal is the Copy Database Wizard.

Page 11: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Copy Database WizardCopy Database Wizard

Page 12: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Moving DatabasesMoving Databases

• You may detach your database and attach your database in a different location.

• You can also move data by doing a backup and a restore to a different location.

Page 13: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Detach TaskDetach Task

Page 14: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Bulk-Inserting XML DataBulk-Inserting XML Data

• You can bulk-insert data to import large amounts of data in SQL Server using T-SQL syntax.

• You can accomplish this by using an OPENROWSET function or a BULK INSERT statement.

Page 15: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Bulk-Logged Recovery ModelBulk-Logged Recovery Model• Choosing a Full database recovery model

would have a big impact on the transaction log when performing BULK INSERT statements.

• To have less impact on the transaction log, you can implement the Bulk-Logged recovery model.

• In contrast to the Full recovery model, the Bulk-Logged model logs bulk operations in a minimal mode.

• This allows the Bulk-Logged model to protect against media failures, provide the best performance, and use the least log space.

Page 16: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

SummarySummary

• In this lesson you learned how to work with relational data in terms of importing and exporting data.

• An interesting capability of SQL Server is the various methods you can use to bulk-import or even export data to the file system using command-line utilities such as bcp or the BULK INSERT statement.

Page 17: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

SummarySummary

• SSIS is the ETL tool you use to perform advanced data migrations and specify data workflows with custom scripting and transformations.

• The power of this tool is that you can use heterogeneous data sources and destinations.

Page 18: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Summary for Certification ExaminationSummary for Certification Examination

• Be able to run the bcp utility. The bcp utility has several options, including creating a format file and specifying your input or output result based on a table or a query.

• It is important to be able to identify the correct syntax to use to perform various bcp statements.

Page 19: Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources

Summary for Certification ExaminationSummary for Certification Examination

• Know how to import and export data. • You need to have a good

understanding of how to import and export data by using BULK INSERT statements or even by using the OPENROWSET function.

• You also can use advanced ETL features with SSIS, and you need to be able to identify which tool to use for each purpose.