Module 8 Importing and Exporting Data. Module Overview Transferring Data To/From SQL Server Importing & Exporting Table Data Inserting Data in Bulk.

Slides:



Advertisements
Similar presentations
Module 3: Creating and Tuning Indexes. Planning Indexes Creating Indexes Optimizing Indexes.
Advertisements

Importing and Exporting Data Exam / 30. Bulk Copy Program (BCP) If you are exporting data using BCP, the account that BCP is running under needs.
Introduction to ETL Using Microsoft Tools By Dr. Gabriel.
Module 12: Auditing SQL Server Environments
Module 17 Tracing Access to SQL Server 2008 R2. Module Overview Capturing Activity using SQL Server Profiler Improving Performance with the Database Engine.
Chapter 5 Data Management. – The Best & Most Convenient Way to Learn Salesforce.com 2 Objectives By the end of the module, you.
Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources.
Module 20 Troubleshooting Common SQL Server 2008 R2 Administrative Issues.
Module 6 Implementing Table Structures in SQL Server ®2008 R2.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
Module 9 Designing an XML Strategy. Module 9: Designing an XML Strategy Designing XML Storage Designing a Data Conversion Strategy Designing an XML Query.
Module 8 Implementing Backup and Recovery. Module Overview Planning Backup and Recovery Backing Up Exchange Server 2010 Restoring Exchange Server 2010.
1 Chapter Overview Transferring and Transforming Data Introducing Microsoft Data Transformation Services (DTS) Transferring and Transforming Data with.
Week 5 – Chap. 5 Data Transfer DBAs often must transfer data to and from text files, Excel spreadsheets, Access, Oracle or other SQL Server databases This.
Copying, Managing, and Transforming Data With DTS.
Module 11: Data Transport. Overview Tools and functionality in Oracle and their equivalents in SQL Server for: Data transport out of the database Data.
Module 9: Transferring Data. Overview Introduction to Transferring Data Tools for Importing and Exporting Data in SQL Server Introduction to DTS Transforming.
1 Access Lesson 6 Integrating Access Microsoft Office 2010 Introductory Pasewark & Pasewark.
Module 13 Automating SQL Server 2008 R2 Management.
Module 9: Managing Schema Objects. Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing.
SSIS Over DTS Sagayaraj Putti (139460). 5 September What is DTS?  Data Transformation Services (DTS)  DTS is a set of objects and utilities that.
SQL Server Integration Services (SSIS) Presented by Tarek Ghazali IT Technical Specialist Microsoft SQL Server (MVP) Microsoft Certified Technology Specialist.
9 Chapter Nine Extracting and Transforming Data with SQL Server 2000.
Module 8 Improving Performance through Nonclustered Indexes.
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
Sofia, Bulgaria | 9-10 October SQL Server 2005 High Availability for developers Vladimir Tchalkov Crossroad Ltd. Vladimir Tchalkov Crossroad Ltd.
SQL/Lesson 4/Slide 1 of 45 Using Subqueries and Managing Databases Objectives In this lesson, you will learn to: *Use subqueries * Use subqueries with.
Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup.
Module 11: Programming Across Multiple Servers. Overview Introducing Distributed Queries Setting Up a Linked Server Environment Working with Linked Servers.
DTS Conversion to SSIS Conversion Best Practices Mike Davis
Module 5 Planning for SQL Server® 2008 R2 Indexing.
IT 456 Seminar 5 Dr Jeffrey A Robinson. Overview of Course Week 1 – Introduction Week 2 – Installation of SQL and management Tools Week 3 - Creating and.
Module 14 Configuring Security for SQL Server Agent.
Populating a Data Warehouse. Overview Process Overview Methods of Populating a Data Warehouse Tools for Populating a Data Warehouse Populating a Data.
Module 16: Performing Ongoing Database Maintenance
Module 10 Assigning Server and Database Roles. Module Overview Working with Server Roles Working with Fixed Database Roles Creating User-defined Database.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
1 Chapter Overview Preparing to Upgrade Performing a Version Upgrade from Microsoft SQL Server 7.0 Performing an Online Database Upgrade from SQL Server.
Module 15 Monitoring SQL Server 2008 R2 with Alerts and Notifications.
Virtual techdays INDIA │ august 2010 SQL Data Loading Techniques Praveen Srivatsa │ Director, AsthraSoft Consulting Microsoft Regional Director,
Today’s Agenda Chapter 7 Review for Midterm. Data Transfer Tools DTS (Data Transformation Services) BCP (Bulk Copy Program) BULK INSERT command Other.
Siebel 8.0 Module 2: Overview of EIM Processing Integrating Siebel Applications.
Module 4 Designing and Implementing Views. Module Overview Introduction to Views Creating and Managing Views Performance Considerations for Views.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
Module 1 Introduction to SQL Server® 2008 R2 and its Toolset.
02 | Data Flow – Extract Data Richard Currey | Senior Technical Trainer–New Horizons United George Squillace | Senior Technical Trainer–New Horizons Great.
Session 1 Module 1: Introduction to Data Integrity
Ch 7. Working with relational data. Transactions Group of statements executed as a group. If all statements execute successfully, changes are committed.
Creating Simple and Parallel Data Loads With DTS.
Best Practices in Loading Large Datasets Asanka Padmakumara (BSc,MCTS) SQL Server Sri Lanka User Group Meeting Oct 2013.
11 Copyright © 2004, Oracle. All rights reserved. Performing a Migration Using Oracle Migration Workbench (Part II)
SSIS ETL Data Resource Management. Create an ETL package using a wizard database server to database server The business goal of this ETL package is to.
©NIIT BCP and DTS Implementing Stored Procedures Lesson 2A / Slide 1 of 23 Objectives In this lesson, you will learn to: Perform bulk copy using the BCP.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Designing Database Solutions for SQL Server
Deploying and Configuring SSIS Packages
Microsoft Office Illustrated
Automating SQL Server Management
Exchanging Data with Other Programs
Module 5: Implementing Data Integrity by Using Constraints
Microsoft SQL Server 2014 for Oracle DBAs Module 7
8 6 MySQL Special Topics A Guide to MySQL.
Bulk Load and Minimal Logging
Chapter 11 Managing Databases with SQL Server 2000
Microsoft SQL Server 2014 for Oracle DBAs Module 9
Ch 10. Maintaining and Automating SQL Server
Presentation transcript:

Module 8 Importing and Exporting Data

Module Overview Transferring Data To/From SQL Server Importing & Exporting Table Data Inserting Data in Bulk

Lesson 1: Transferring Data To/From SQL Server Overview of Data Transfer Available Tools for Data Transfer Improving the Performance of Data Transfers Disabling & Rebuilding Indexes Disabling & Enabling Constraints Demonstration 1A: Disabling & Enabling Constraints

Scenarios Copying or moving between servers Exporting query data to a file Importing table data from a file Copying to or from a view Transforming collations Overview of Data Transfer ETL: Extract Transform Load

Available Tools for Data Transfer Bulk Copy Program (bcp) BULK INSERT C:\> bcp XML Bulk Load Import / Export Wizard OPENROWSET(BULK)

Notes Page Over-flow Slide. Do Not Print Slide. See Notes pane.

Improving the Performance of Data Transfers Disable constraints, indexes, and triggers  No need to check constraints as each row is loaded  Indexes don’t need to be maintained during import  Important to check business requirements before disabling triggers Minimizing locking  Consider the use of TABLOCK to speed up the import Minimizing logging  Database must be in BULK_LOGGED or SIMPLE model  Additional requirements on table structure and locking Minimize data conversions  Use native format when transferring data between SQL Servers

Notes Page Over-flow Slide. Do Not Print Slide. See Notes pane.

Disabling & Rebuilding Indexes Disabling an index  Prevents user access to the index  Prevents access to the data if it is a clustered index  Keeps index definition in metadata  Speeds up data import in tables, as the index is not maintained during the import Enabling an index  Rebuilds the index entirely  Is easy to automate as the metadata is still present Enabling and disabling indexes can be used as an alternative to dropping and recreating indexes

Disabling & Enabling Constraints Disabling PRIMARY KEY and UNIQUE constraints  Is achieved by disabling the associated index  Causes associated indexes to be rebuilt when enabled  Can cause failures during re-enabling if duplicate values exist  Also causes associated foreign key constraints to be disabled Disabling FOREIGN KEY and CHECK constraints  Can be performed directly on the constraint  Causes existing data to not be verified when re-enabled When you enable a FOREIGN KEY or CHECK constraint, existing data is not verified by default

Demonstration 1A: Disabling & Enabling Constraints In this demonstration, you will see how to disable and re-enable a Check constraint

Lesson 2: Importing & Exporting Table Data Overview of SQL Server Integration Services Demonstration 2A: Working with SSIS SQL Server Import/Export Wizard Demonstration 2B: Using the Import/Export Wizard

Overview of SQL Server Integration Services SSIS is a rich framework to develop ETL solutions SSIS packages contain  Data Sources and Destinations  Control and Data Flows  Transformations to be performed SSIS packages can be run using  dtsrun command line utility  SQL Server Agent jobs SSIS packages developed using  SQL Server Business Intelligence Development Studio (BIDS)  Import / Export Wizard

Demonstration 2A: Working with SSIS In this demonstration you will see how to use SQL Server Integration Services to export data from a table to a flat file

SQL Server Import/Export Wizard Easy to use wizard for creating an SSIS package that performs simple data transfers

Demonstration 2B: Using the Import/Export Wizard In this demonstration you will see how to use the Import/Export Wizard to export data to a CSV file

Lesson 3: Inserting Data in Bulk bcp Utility Demonstration 3A: Working with bcp BULK INSERT Statement Demonstration 3B: Working with BULK INSERT OPENROWSET Function Demonstration 3C: Working with OPENROWSET

BCP Utility Is a command line tool to import and export data Uses a format file when transferring between SQL Instances Creating a format file: bcp Adv.Sales.Currency format nul -T -c –x -f Cur.xml Exporting data into a file: bcp Adv.Sales.Currency out Cur.dat -T –c Importing data using a format file: bcp tempdb.Sales.Currency2 in Cur.dat -T -f Cur.xml Creating a format file: bcp Adv.Sales.Currency format nul -T -c –x -f Cur.xml Exporting data into a file: bcp Adv.Sales.Currency out Cur.dat -T –c Importing data using a format file: bcp tempdb.Sales.Currency2 in Cur.dat -T -f Cur.xml

Demonstration 3A: Working with bcp In this demonstration, you will see how to import a file using the bcp utility

BULK INSERT Statement Provides options similar to bcp Runs in the SQL Server process Has CHECK_CONSTRAINTS and FIRE_TRIGGERS options Can be executed within a user-defined transaction BULK INSERT AdventureWorks.Sales.OrderDetail FROM 'f:\orders\neworders.txt' WITH ( FIELDTERMINATOR =' |', ROWTERMINATOR =' |\n' ); GO BULK INSERT AdventureWorks.Sales.OrderDetail FROM 'f:\orders\neworders.txt' WITH ( FIELDTERMINATOR =' |', ROWTERMINATOR =' |\n' ); GO

Demonstration 3B: Working with BULK INSERT In this demonstration, you will see how to import a file using the BULK INSERT command

OPENROWSET Function Allows access to remote data by connecting to a remote data source using an OLE-DB provider Offers a built-in BULK provider for bulk imports from files  Can be used in a FROM clause with full functionality  Can use INSERT.. SELECT to insert data  Offers unique table hints to control operation SELECT * FROM OPENROWSET( BULK 'c:\mssql\export.csv', FORMATFILE = 'c:\mssql\format.fmt', FIRSTROW = 2) AS a; GO SELECT * FROM OPENROWSET( BULK 'c:\mssql\export.csv', FORMATFILE = 'c:\mssql\format.fmt', FIRSTROW = 2) AS a; GO

Notes Page Over-flow Slide. Do Not Print Slide. See Notes pane.

Demonstration 3C: Working with OPENROWSET In this demonstration, you will see how to import a file using OPENROWSET

Lab 8: Importing and Exporting Data Exercise 1: Import the Excel spreadsheet Exercise 2: Import the CSV file Exercise 3: Create and test an extraction package Challenge Exercise 4: Compare loading performance (Only if time permits) Logon information Estimated time: 45 minutes

Lab Scenario Proseware regularly receives updates of currencies and exchange rates from an external provider. One of these files is provided as an Excel spreadsheet, the other file is provided as a comma-delimited text file. You need to import both these files into tables that will be used by the Direct Marketing team within Proseware. Periodically the Marketing team requires a list of prospects that have not been contacted within the last month. You need to create and test a package that will extract this information to a file for them. You are concerned about the import performance for the exchange rate file and you are considering disabling constraints and indexes on the exchange rate table during the import process. If you have time, you will test the difference in import performance.

Lab Review What kind of information needs to be present in a format file? Which tool or command should you use to read an entire XML document into a column in a SQL Server table?

Module Review and Takeaways Review Questions Best Practices