Создание ssis пакета visual studio 2019
Для реализации простенького пакета необходимо установить надстройку SSDT (Sql server data tools) для вашей Visual Studio.
Допустим, вам необходимо перенести данные с одного сервера на другой. Первыми мыслями о решении данной задачи, как правило, являются следующие варианты: выгрузить данные с одного сервера в excel и воспользоваться мастером импорта или воспользоваться линком между серверами, если он, конечно, есть.
Однако линка может и не быть, а задача по переносу данных может оказаться периодичной. Тогда вам каждый раз придется повторять выгрузку данных и их импорт. Это неудобно.
В таких случаях на помощь как раз приходит SSIS. В других случаях, кстати тоже.
Что же представляет из себя SSIS? Это набор контейнеров, соединяемых между собой. Программа состоит из потока управления (Control Flow), который может включать в себя поток данных (Data Flow). Вот так выглядит стартовое окно проекта в Visual Studio 2017.
Итак, нам необходимо перенести данные таблицы с одного сервера на другой. Для начала нам необходимо создать соединения к этим серверам. Ниже представлен процесс создания:
Из списка выбираем необходимый нам тип соединения. Мы рассмотрим создание соединение OLEDB.
После того, как мы добавили необходимые соединения наступило время для создания в нашем Control Flow задачи потока данных. Для того в SSIS toolbox необходимо выбрать контейнер Data Flow Task (Задача потока данных).
Далее необходимо перейти в контейнер, который мы только что создали и выбрать Источник данных (Source) и назначение данных(Destination).
Перейдем к настройке источника данных. Здесь нам необходимо выбрать соединение, где находится таблица, из которой мы хотим перенести данные. Далее выбираем таблицу. Стоит отметить, что также необходимые данные можно выбрать через Sql запрос (для этого необходимо выбрать Sql command при выборе data access mode).
После настройки источника необходимо настроить назначение данных. Для этого выбираем соединение и таблицу, в которую будем переливать данные. После чего переходим на вкладку Mappings, для того чтобы сопоставить столбцы. Очень важно, чтобы у вас совпадали типы данных, потому что иначе пакет не отработает корректно.
На этом занятии вы создадите простой пакет для извлечения, преобразования и загрузки, который будет извлекать данные из отдельного источника неструктурированных файлов, преобразовывать их с помощью двух преобразований типа "уточняющий запрос", а затем записывать преобразованные данные в копию таблицы фактов FactCurrencyRate, находящуюся в образце базы данных AdventureWorksDW2012. На этом занятии вы узнаете, как создавать пакеты, добавлять и настраивать подключения к источникам данных и назначениям, а также работать с новыми компонентами потока управления и потока данных.
Перед созданием пакета необходимо ознакомиться с форматированием в источнике данных и назначении. После этого можно определить преобразования, необходимые для сопоставления источника данных с назначением.
Предварительные требования
Для выполнения упражнений в этом учебнике требуются средства Microsoft SQL Server Data Tools, набор примеров пакетов и образец базы данных.
Чтобы скачать все пакеты занятий этого учебника, выполните указанные ниже действия.
Выберите файл Creating a Simple ETL Package.zip и нажмите кнопку Далее.
Когда файл скачается, распакуйте его содержимое в локальный каталог.
Чтобы установить и развернуть образец базы данных AdventureWorksDW2012, см. страницу Установка и настройка образца базы данных AdventureWorks — SQL.
Обзор исходных данных
Для этого учебника исходные данные представлены в виде набора курсов валют, содержащегося в неструктурированном файле SampleCurrencyData.txt. Данные источника в этом файле имеют четыре столбца: средний курс валюты, ключ валюты, ключ даты и курс на конец дня.
Вот пример исходных данных в файле SampleCurrencyData.txt:
При работе с исходными данными неструктурированных файлов важно понимать, как диспетчер подключений к неструктурированным файлам интерпретирует их. Если неструктурированный файл является документом в Юникоде, диспетчер соединений с неструктурированными файлами определяет все столбцы как [DT_WSTR] с шириной, по умолчанию равной 50. Если неструктурированный файл является документом в кодировке ANSI, столбцы определяются как [DT_STR] с шириной по умолчанию, равной 50. Возможно, потребуется изменить эти настройки, чтобы оптимизировать столбцы для конкретных данных. Необходимо узнать тип данных в назначении, а затем выбрать этот тип в диспетчере подключений к неструктурированным файлам.
Обзор данных назначения
Назначением исходных данных является копия таблицы фактов FactCurrencyRate в базе данных AdventureWorksDW. Таблица фактов FactCurrencyRate имеет четыре столбца и связи с двумя таблицами измерений, как показано в следующей таблице.
Имя столбца | Тип данных | Таблица уточняющих запросов | столбцом подстановки |
---|---|---|---|
AverageRate | FLOAT | None | None |
CurrencyKey | int (FK) | DimCurrency | CurrencyKey (PK) |
DateKey | int (FK) | DimDate | DateKey (PK) |
EndOfDayRate | FLOAT | None | None |
Сопоставление исходных данных с назначением
Анализ форматов данных источника и назначения показывает, что для значений CurrencyKey и DateKey требуются уточняющие запросы. Преобразования, которые выполняют эти уточняющие запросы, получают эти значения из таблиц измерений DimCurrency и DimDate.
In this lesson, you create a simple ETL package that extracts data from a single flat file source, transforms the data using two lookup transformations, and writes the transformed data to a copy of the FactCurrencyRate fact table in the AdventureWorksDW2012 sample database. As part of this lesson, you learn how to create new packages, add and configure data source and destination connections, and work with new control flow and data flow components.
Before creating a package, you need to understand the formatting used in both the source data and the destination. Then, you be ready to define the transformations necessary to map the source data to the destination.
Prerequisites
This tutorial relies on Microsoft SQL Server Data Tools, a set of example packages, and a sample database.
To install the SQL Server Data Tools, see Download SQL Server Data Tools.
To download all of the lesson packages for this tutorial:
Select the DOWNLOAD button.
Select the Creating a Simple ETL Package.zip file, then select Next.
After the file downloads, unzip its contents to a local directory.
To install and deploy the AdventureWorksDW2012 sample database, see Install and configure AdventureWorks sample database - SQL.
Look at the source data
For this tutorial, the source data is a set of historical currency data in a flat file named SampleCurrencyData.txt. The source data has the following four columns: the average rate of the currency, a currency key, a date key, and the end-of-day rate.
Here is an example of the source data in the SampleCurrencyData.txt file:
When working with flat file source data, it's important to understand how the Flat File connection manager interprets the flat file data. If the flat file source is Unicode, the Flat File connection manager defines all columns as [DT_WSTR] with a default column width of 50. If the flat file source is ANSI-encoded, the columns are defined as [DT_STR] with a default column width of 50. You probably have to change these defaults to make the string column types more applicable for your data. You need to look at the data type of the destination, and then choose that type within the Flat File connection manager.
Look at the destination data
The destination for the source data is a copy of the FactCurrencyRate fact table in AdventureWorksDW. The FactCurrencyRate fact table has four columns, and has relationships to two dimension tables, as shown in the following table.
Column Name | Data Type | Lookup Table | Lookup Column |
---|---|---|---|
AverageRate | float | None | None |
CurrencyKey | int (FK) | DimCurrency | CurrencyKey (PK) |
DateKey | int (FK) | DimDate | DateKey (PK) |
EndOfDayRate | float | None | None |
Map the source data to the destination
Our analysis of the source and destination data formats indicates that lookups are necessary for the CurrencyKey and DateKey values. The transformations that perform these lookups get those values by using the alternate keys from the DimCurrency and DimDate dimension tables.
SQL Server Integration Services is Microsoft’s powerful platform for implementing Extract, Transform and Load (ETL) solutions. It allows SQL Server Professionals to solve complex business intelligence tasks and work with a wide range of data sources. Microsoft provides a graphical tool for designing and developing Integration Services projects. This tool has always been an integral part of the Visual Studio. However, the name of this tool as well as the method of its installation varies from version to version of Visual Studio (VS). In this article, we are going to illustrate how to install the SQL Server Integration Services development tool for the latest version of Visual Studio.
Solution
As mentioned above, Microsoft’s tool for developing Integration Services projects is named differently in different versions of the Visual Studio. For example, for the SQL Server 2008/2008R2 integration services, this tool was VS 2008’s Business Intelligence Development Studio (BIDS) and came with the SQL Server installation media. In VS 2010, the tool was renamed as the SQL Server Data Tools (SSDT) and shipped as a part of the SQL Server 2012 installation media. In VS 2012/2013, this tool was slightly renamed as SSDT-BI and needed a separate download. In VS 2015, it was called SSDT and needed a separate download. In VS 2017, this tool could be installed during the VS installation. It is worth mentioning that BIDS, SSDT-BI, and SSDT can be used not only for working with SSIS projects, but also SQL Server Analytical Services and SQL Server Reporting Services projects. Additionally, it is important to note that SSDT is backward compatible, which means that projects designed on the newer versions of SSDT can run on older versions of SQL Server.
Now, after that historical review, let’s move to the latest release of Visual Studio – VS 2019 and see what this version provides as an SSIS development tool. For this version of the VS, there is no standalone installer for SSDT. While in this version the core components of SSDT for creating database projects have remained integrated in Visual Studio, the Integration Services, Analysis Services, and Reporting Services projects have become just an extension of the VS. Thus, in order to install the tool for SSIS development, we first need to install VS 2019. Therefore, we will divide our article into two parts. In the first part we will describe the installation of VS 2019 and in the second part, will illustrate the SSIS’s extension installation.
Installing Visual Studio 2019
To download Visual Studio 2019 we will use the following link.
For our example, we will download the free, Community edition of this product:
Then, we will click on "Free download". After downloading the .exe file, we will double click on it to start the process:
The Visual Studio installer starts and after some time the following window is opened:
To add SSDT, we scroll down and choose "Data storage and processing". Then, we press the "Install" button and wait for the installation to complete:
After installation, restart is required, so we press "Restart":
After having our computer rebooted, we start Visual Studio:
On the next screen, just to keep our example simple, we just click "Not now, maybe later." instead of signing in:
After that, we choose the theme and click on "Start Visual Studio":
Well, we have installed Microsoft Visual Studio 2019 on our computer. Now, it’s time to add the extension for developing Integration Services projects.
Adding the SSIS Projects extension to the Visual Studio 2019
When Visual Studio is opened, we click on "Continue without code" to add the necessary extension:
In this window, we click on "Extensions" > "Manage Extensions":
In the search bar of the opened window, we type "Integration Services" to easily locate the extension. From the appeared list we choose "SQL Server Integration Services Projects" and press "Download":
Then, we will execute the downloaded .exe file:
The installation of the extension begins. Now, we will follow some simple steps. In the next window we click "OK":
After that, we click "Next" to continue:
If you receive the following message, you probably have SQL Server Management Studio opened:
Close it and click "OK". The process should continue:
Finally, the setup is completed and we have our extension installed:
Now, we are ready to create Integration Services projects. In Visual Studio, we choose "Create a new project":
In the next window, we type "integration" to find "Integration Services Project" and click on it:
We choose a name for our project:
Hence, it is ready! We opened the interface where we can design and develop SSIS 2019 packages:
Conclusion
To sum up, we reviewed the updates related to the tool for SQL Server Integration Services projects development in the VS 2019. As we have seen, in this version of the VS, the tool for designing SSIS projects is installed as an extension of the Visual Studio. We have also explored how to install Visual Studio 2019 and how to add the Integration Services Projects extension to it.
Next Steps
Please find additional, topic-related information using the following links:
Related Articles
Popular Articles
About the author
Sergey Gigoyan is a database professional with more than 10 years of experience, with a focus on database design, development, performance tuning, optimization, high availability, BI and DW design.
Article Last Updated: 2020-07-09
Comments For This Article
I think it is also worth noting in this post, which I believe is incredibly useful for developers who are migrating from one version to the next, that if you used to work with TFS as your source control service, you should probably plan on migrating to Azure Dev Ops when you move to 2019.
Sergey, thanks for this article. I want to share with you all the audience that I installed VS 2019, SSDT and extensions with success. But, when I opened an integration services project package with a Data mining model training object on it a �No such interface supported� error came up. This package runs well in VS2017 and SSDT version 15.9.3. Any suggestion?
Sergey, great article, it is nice to have a well documented installation guide for 2019 because as you metioned the installation methods keep changing. Thanks!
Keep in mind that if you want source control integration with Team Foundation Server, you need the full-blown Visual Studio. There is no Team Foundation Explorer plug-in for Visual Studio 2015, so you can�t use the shell of SSDT.
Creating a Project
Start Visual Studio. If it�s the first time, you might get a prompt asking which settings Visual Studio should use. You can pick the Business Intelligence settings. When Visual Studio has started, go to File > New > Project.
In the New Project menu, enter a name for the project and specify a location to save the project.
When you create a project, Visual Studio will create a solution first and add the project to that solution. By default, the solution has the same name as the project. If you want to add multiple projects to one solution, you might want to change the solution name. If you have source control integrated into Visual Studio, you will have an extra checkbox asking you if you want to add the project to source control.
When you click OK, the solution and the project will be created and an empty package will be added to the project. You can view the project structure in the Solution Explorer window:
When there�s only one project, the solution will not be displayed.
The SQL Server Data Tools Interface for Integration Services
Let�s take a look at our development environment for creating SSIS packages. Keep in mind that most of the windows are dockable, which means you can move them around, so it�s possible you do not have the exact same view as in this screenshot.
- This is your canvas. Here you drag items from the toolbox and you connect them with each other to create a workflow. This will be discussed in more detail in the next sections of the tutorial. The package canvas has multiple tabs:
- The control flow. Here you can have multiple tasks which you can connect with each other. The control flow is important as it defines what your package actually does.
- The data flow. This is a special task of the control flow. Here you move data around between sources and destinations, and you can transform the data while it is in memory.
- Parameters. You can define parameters to make your package more flexible.
- Event Handlers. This are special �control flow�-like canvasses where you can define tasks that will only execute if a specific event occurs. Event handlers fall out of scope of this tutorial.
- Package Explorer. A tree-view of all the objects inside your package.
Everything mentioned here will be explained in more detail in the following section in the tutorial.
There�s only one window missing from this view: the variables. When you create your first SSIS project, this window is hidden. You can right-click on the canvas and select Variables to open the window.
Variables are used to make your package more flexible and change properties on the fly when a package is running. The difference between parameters and variables is that parameters cannot change value once the package has started executing, while variables can. Parameters are used as input for the package before it starts.
Читайте также: