SQL Server Performance

  • Home
  • Articles
  • Forums
  • Tips
  • Training
  • FAQ's
  • Blogs
  • Software
  • Books
  • About Us
RSS Feeds
Sign in | Join


Article Topics

All Articles
Performance Tuning
Audit
Business Intelligence
Clustering
Reporting Services
SQL Azure
Developer
General DBA
ASP.NET / ADO.NET
SQL Azure

USEFUL SITES :

ASP.NET Tutorials
Windows and SQL Azure Tutorials
Cloud Hosting Magazine
SharePoint Tutorials
Windows Server Help

Write for Us

Share your SQL Server knowledge with others and raise your profile in the community More...
Latest Articles

A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server

More     
 
Latest FAQ's

Add Node to A SQL Server failover Cluster failed with invalid ...
SQL Server Destination remote server error
Setting Up Data And Log Files For SQL Server
Will Check Constraints Improve Database Performance?

More     
   
Latest Software Reviews

dbForge Review
Spotlight on ApexSQL Diff - Server-based database comparison tool ...
Spotlight on ApexSQL Data Diff - Server-based database comparison tool ...
Spotlight on ApexSQL Doc 2008

More     

articles >> general dba >> Execute SQL and Bulk Insert Tasks in ...

Execute SQL and Bulk Insert Tasks in SSIS

By : Ashish Kumar Mehta
Jun 03, 2009

Introduction

SQL Server Integration Services (SSIS) is a Business Intelligence tool which can be used by database developers or administrators to perform Extract, Transform & Load (ETL) operations. In my previous article entitled Using Data Profiler Task and FTP Task in SQL Server 2008 Integration Services I discussed how to use the Data Profiling Task and the FTP Task which are  available in SQL Server 2005 Integration Services and later versions. In this article I will examine the use of the Execute SQL Task and the Bulk Insert Task which are available in SQL Server 2005 and later versions.

Overview of SQL Server Tasks in SSIS 2005 & Later Versions

The SQL Server tasks within SSIS can be used to copy, modify and delete SQL Server objects and data. The different types of SQL Server Tasks which are available in SSIS are Execute SQL Task, Bulk Insert Task, Transfer Database Task, Transfer Error Message Task, Transfer Job Task, Transfer Login Task, Transfer Master Stored Procedure Task and Transfer SQL Server Objects Task. If you are new to SQL Server Integration Services then I would recommend you to start with my previous article entitled SQL Server 2008 Integration Services Tasks. In this article you will see an example for how to configure and use Execute SQL Task and Bulk Insert Task.

Overview of Execute SQL Task

The Execute SQL Task can be used to execute any TSQL code such as truncating a staging table, executing queries, stored procedures etc from a SSIS Package. This task can also be used in combination with For Loop and Foreach Loop containers to run multiple TSQL statements.

Overview of Bulk Insert Task

The Bulk Insert Task can be used to insert data from a text file or a flat file into a SQL Server Table in the same way the  BULK INSERT statement or   BCP.EXE command line tool is used. It is advised to use the Bulk Insert Task in applications which require quick loading of large amounts of data.

 

Example Using Execute SQL Task and Bulk Insert Task

In this example we will use an Execute SQL Task to create an Employee table within the SSISExample database and then use the Bulk Insert Task to insert the data into an Employee table from a comma separated text file.

 

1.    Create a new SQL Server Integration Services Project and rename the default package BulkInsertTaskExample.dtsx

2.    Double click the BulkInsertTaskExample.dtsx package to open it up in Design Mode.

3.    Drag and drop “Execute SQL Task” from the toolbox to the Control Flow window and rename it “Create Employee Table”. Then double click the Execute SQL Task to open up Execute SQL Task Editor as shown in the below snippet.

 

In Execute SQL Task Editor, you will need to configure a connection to a SQL Server, for the SQLSourceType property choose  Direct Input from the drop down list. Next, copy the below TSQL code and paste it into the SQLStatement textbox. Finally click OK to save changes in Execute SQL Task Editor.

 

Use SSISExample

GO

 

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Employee]') AND type in (N'U'))

DROP TABLE [dbo].[Employee]

GO

 

CREATE TABLE [dbo].[Employee]

(

                [EmpID] [int] NOT NULL,

                [EmployeeName] [nvarchar](100)  NULL,

                [Title] [nvarchar](100)  NULL,

                [Age] [int] NULL,

) ON [PRIMARY]

GO

 


    Next Page>>    








C# Help and Tutorials | PHP MySQL Tutorial | Sharepoint Tutorial | Azure Tutorial | Cloud Hosting Magazine | ASP.NET Tutorials | Windows Server Help | Windows Phone Pro | Silverlight Ace | Visual Studio Tutorials | Home | Peformance Articles | Audit Articles | Business Intelligence Articles | Clustering Articles | Developer Articles | Reporting Services Articles | DBA Articles | ASP.NET / ADO.NET Articles | SQL Server Training Videos | DBA FAQ's | Developer Peformance FAQ's | DBA Peformance FAQ's | Developer FAQ's | Clustering FAQ's | Error Messages | Audit Tool Reviews | Backup Tool Reviews | Coding Tool Reviews | Compare Tool Reviews | Documentation Tool Reviews | Design Tool Reviews | Monitoring Tool Reviews | Log Tool Reviews | Reporting Tool Reviews | Clustering Tool Reviews | Security Tool Reviews | Change Management Tool Reviews | Remote Access Tool Reviews | Book Reviews | Security Tool Reviews | ADO.NET / ASP.NET | Administration | Analysis/OLAP Services | Application Development | Configuration | Components | ETL | Hardware | High Availability | Hints | Index | Misc | Operating Systems | Performance Tuning | Replication | T-SQL | Views


              © 2010 Jude O'Kelly. All rights reserved