I can speak SQL

Fluent SQL speaker

Posts Tagged ‘SQL SERVER’

How to install Git Source Control Provider on SQL Server Data Tools

Posted by kulmam92 on September 5, 2013

Git Source Control Provider

If you decide to use Git as a SCM (Source Control Management) system, you may decide to use Git Source Control Provider since it’s integrated to the Visual Studio (SQL Server Data Tools). This is not available from the Extension Manager’s online gallery if you try to search it from the SQL Server Data Tools. However, you can download Git Source Control Provider from its codeplex page : http://gitscc.codeplex.com/.

GitSourceControlProvider

If you click the “Installer for VS2010, VS2012”, “GitSccProvider.vsix” will be downloaded. Double clicking that file should install Git Source Control Provider but you will see the following error message.

ErrorMessage

The message means that SQL Server Data Tools which is a Visual Studio 2010 shell edition is not supported by Git Source Control Provider. Fortunately, there’s a workaround.

Workaround

What is VSIX

It will be easier for you to understand what I’m doing, if you know what VSIX is. Below is the definition of VSIX quoted from the Quan To’s Visual Studio Extensibility blog.

The VSIX file is the unit of deployment for a Visual Studio 2010 Extension. Visual Studio will recognize the VSIX extension and install the contents of the file to the right location.

A VSIX file is a zip file that uses the Open Packaging Convention. You can rename the .VSIX extension to .ZIP and use any zip browser (including the Windows File Explorer) to browse its contents.In short it’s a deployment format for a Visual Studio Extension.

extension.vsixmanifest

One of key files in VSIX is “extension.vsixmanifest”.

extension.vsixmenifest.edit

This file is the manifest that describes the extension. Basically this is a XML file. The details about XML schema can be found from VSIX Extension Schema 2.0 Reference. Element called “<SupportedProducts>” tells compatible versions and editions. As you can see “IntegratedShell” is not listed.

<SupportedProducts> <VisualStudio Version=”10.0″> <Edition>Ultimate</Edition> <Edition>Premium</Edition> <Edition>Pro</Edition> </VisualStudio> <VisualStudio Version=”11.0″> <Edition>Ultimate</Edition> <Edition>Premium</Edition> <Edition>Pro</Edition> </VisualStudio> </SupportedProducts>

So I added “IntegratedShell” to the <SupportedProducts> element like below and saved the changes.

extension.vsixmenifest.contents

You will see the following message, if you close the notepad.

extension.vsixmenifest.save

Now you are ready to install Git Source Control Provider. If you double click the “GitSccProvider.vsix” file, you will the following installation popup.

Install

Summary

Even though Git Source Control Provider doesn’t officially support Visual Studio Shell edition (SQL Server Data Tools), it’s working fine after the installation.  I modified the supported version list to fool the installer. I hope the developer of  Git Source Control Provider adds Visual Studio Shell edition to the official supported list.

Advertisements

Posted in Deployment, SQL SERVER, SSIS | Tagged: , , , , , , , , | Leave a Comment »

SSISDB ERD – A Journey to DB deployment automation

Posted by kulmam92 on June 17, 2013

I decided to reverse engineer the SSISDB to have a better understanding of the SSIS catalog. Reza Rad posted a really good article called “SSIS 2012 Catalog series“. However, I thought it would be better to create my own version of an ERD to have better understanding of it. Here’s what i came up with.

SSISDB ERD

SSIS ERD

Yon can download the pdf version of this from SSISDB_ERD

Table

Main tables

Object related tables

There are four object tables: folder, environment, project and package. I think you can easily figure out the purpose of each table. Other than these key tables are the tables for relationship (environment_reference), parameters, versions and permissions. SSISDB keeps a project’s previous versions as binary data in the internal.object_versions table. You can specify how many versions that you want to keep by using the properties of an SSIS catalog.

image

[Operations]

This table contains one row for each operation in the Integration Services catalog. You can track all logical operations that were performed on the server using this table, such as project deployment or package execution. Below are the operation_type values from BOL:

operation_type Value operation_type Description object_id Description object_name Description
1 Integration Services initialization NULL NULL
2 Retention window (SQL Agent job) NULL NULL
3 MaxProjectVersion (SQL Agent job) NULL NULL
101 deploy_project (Stored procedure) Project ID Project name
106 restore_project (Stored procedure) Project ID Project name
200 create_execution and start_execution (Stored procedures) Project ID NULL
202 stop_operation (Stored procedure) Project ID NULL
300 validate_project (Stored procedure) Project ID Project name
301 validate_package (Stored procedure) Project ID Package name
1000 configure_catalog (Stored procedure) NULL NULL

[Executions]

[executions] has a one-to-one relationship with [operations], which means the [execution] table is a subset of the [operations] table. If you look at the ERD closely, the relationship from operation to execution is made only when the operation type is 200 – create_execution and start_execution (Stored procedures). This means only operation_type value 200 will generate a record in the execution table.

image

If you want to know which package in a project was executed, you can use the following query. This is the creation script of the [catalog].[executions] view.

SELECT     execs.[execution_id],
execs.[folder_name],
execs.[project_name],
execs.[package_name],
execs.[reference_id],
execs.[reference_type],
execs.[environment_folder_name],
execs.[environment_name],
execs.[project_lsn],
execs.[executed_as_sid],
execs.[executed_as_name],
execs.[use32bitruntime],
opers.[operation_type],
opers.[created_time],
opers.[object_type],
opers.[object_id],
opers.[status],
opers.[start_time],
opers.[end_time],
opers.[caller_sid],
opers.[caller_name],
opers.[process_id],
opers.[stopped_by_sid],
opers.[stopped_by_name],
opers.[operation_guid] as [dump_id],
opers.[server_name],
opers.[machine_name],
ossysinfos.[total_physical_memory_kb],
ossysinfos.[available_physical_memory_kb],
ossysinfos.[total_page_file_kb],
ossysinfos.[available_page_file_kb],
ossysinfos.[cpu_count]
FROM       [internal].[executions] execs INNER JOIN [internal].[operations] opers
ON execs.[execution_id]= opers.[operation_id]
LEFT JOIN [internal].[operation_os_sys_info] ossysinfos
ON ossysinfos.[operation_id]= execs.[execution_id]
WHERE      opers.[operation_id] in (SELECT id FROM [internal].[current_user_readable_operations])
OR (IS_MEMBER(‘ssis_admin’) = 1)
OR (IS_SRVROLEMEMBER(‘sysadmin’) = 1)

Message related tables

If you want to check the execution log of a package, these are the tables that you need to query. [operation_messages] and [event_messages] have a one-to-one relationship similar to [operation] and [event]. [event_messages] is a subset of [operation_messages]. The below is the source code of the [catalog].[event_messages] view.

Declare @ExecutionID NVarChar(max)
select @ExecutionID=N’132′
SELECT     opmsg.[operation_message_id] as [event_message_id],
opmsg.[operation_id],
opmsg.[message_time],
opmsg.[message_type],
opmsg.[message_source_type],
opmsg.[message],
opmsg.[extended_info_id],
eventmsg.[package_name],
eventmsg.[event_name],
message_source_name =
CASE
WHEN (opmsg.message_source_type = 10) THEN ‘ISServerExec’
WHEN (opmsg.message_source_type = 20) THEN ‘Transact-SQL stored procedure’
ELSE eventmsg.message_source_name
END,
eventmsg.[message_source_id],
eventmsg.[subcomponent_name],
eventmsg.[package_path],
eventmsg.[execution_path],
eventmsg.[threadID],
eventmsg.[message_code]
FROM       [internal].[operation_messages] opmsg LEFT JOIN [internal].[event_messages] eventmsg
ON opmsg.[operation_message_id] = eventmsg.[event_message_id]
WHERE      opmsg.[operation_id] = @ExecutionID

If you execute an SSIS package deployed to a SSIS catalog and it fails, you will see a message similar to the following.

Executed as user: NT Service\SQLSERVERAGENT. Microsoft (R) SQL Server Execute Package Utility  Version 11.0.2100.60 for 32-bit  Copyright (C) Microsoft Corporation. All rights reserved.    Started:  4:09:59 PM  Package execution on IS Server failed. Execution ID: 120092, Execution Status:4.  To view the details for the execution, right-click on the Integration Services Catalog, and open the [All Executions] report  Started:  4:09:59 PM  Finished: 4:10:27 PM  Elapsed:  28.641 seconds.  The package execution failed.  The step failed.

You will need to use either a prebuilt standard report or query the SSISDB tables to get a detailed error message. The following screenshot shows where you can locate that report. If you decide to query the SSISDB, you may want to consider using the SSIS Reporting Pack developed by Jamie Thomson.

image

Table definition

Here I list the tables and its definitions copied from BOL.

Schema

Table name

Definition

internal catalog_encryption_keys Contains SSISDB encryption key
internal catalog_properties Contains the properties of the Integration Services catalog.
internal data_type_mapping Contains SSIS data type and SQL data type mapping
internal environment_permissions
internal environment_references Contains the environment references for all projects in the Integration Services catalog.
internal environment_variables Contains the environment variable details for all environments in the Integration Services catalog.
internal environments Contains the environment details for all environments in the Integration Services catalog. Environments contain variables that can be referenced by Integration Services projects.
internal event_message_context
internal event_messages Contains information about all messages passed during events like OnWarning, OnError
internal executable_statistics Contains Detailed execution log for each executable
internal executables Contains Information about each executable object in packages
For example : Package itself, Execute SQL Task, ETC.
internal execution_component_phases Contains Detailed execution log for each data flow component.
internal execution_data_statistics Contains Number of rows sent through data flow and few other details
internal execution_data_taps Contains information about data taps
Data Taps are new features in SSIS 2012 which provides ability to log whole data stream in one of data flow’s data paths. and the best part of story is that you can add and remove data taps to a package at the time of execution
internal execution_parameter_values Contains the actual parameter values that are used by Integration Services packages during an instance of execution.
internal execution_property_override_values Contains information about property values that set at the time of execution of package and overrides default values.
internal executions Contains the instances of package execution in the Integration Services catalog. Packages that are executed with the Execute Package task run in the same instance of execution as the parent package. With every execution of package, an Execution_id will be assigned
internal extended_operation_info Contains extended information for all operations in the Integration Services catalog.
internal folder_permissions
internal folders Contains the folders in the Integration Services catalog.
internal object_parameters Contains the parameters for all packages and projects in the Integration Services catalog.
internal object_versions Contains the versions of objects in the Integration Services catalog. In this release, only versions of projects are supported in this view.
internal operation_messages Contains messages that are logged during operations in the Integration Services catalog.
internal operation_os_sys_info Contains system information like cpu count, available physical memory and total physical memory at the time of operation
internal operation_permissions Contains the effective permissions for the current principal for all objects in the Integration Services catalog.
internal operations Contains the details of all operations in the Integration Services catalog. Each operation can be applied to an object and have a status as a result.
internal packages Contains the details for all packages that appear in the Integration Services catalog.
internal project_permissions
internal projects Contains the details for all projects that appear in the Integration Services catalog.
internal validations Contains the details of all project and package validations in the Integration Services catalog.

Scripts

Code definition tables

Reza Rad shared a script that creates code conversion tables. I created and added a table for permsssion_type. You can download the script from SSISDB_CodeTables.

Posted in Deployment, SQL SERVER, SSIS | Tagged: , , , , | 1 Comment »

Building SSIS 2012 using MSBuild – A Journey to DB deployment automation

Posted by kulmam92 on June 7, 2013

This post is the first in a series of entries I am planning to write detailing my experience while attempting to create a process in deploying a DB schema, SSIS and SSRS.

SQL Server Data Tools – Visual Studio Shell

SQL Server Data Tools (SSDT) is an extension of the environment provided by Visual Studio 2010 Shell.

VisualStudioShell_thumb

Wikipedia describes Visual Studio Shell

Visual Studio 2008 introduced the Visual Studio Shell that allows for development of a customized version of the IDE. The Visual Studio Shell defines a set of VSPackages that provide the functionality required in any IDE. On top of that, other packages can be added to customize the installation. The Isolated mode of the shell creates a new AppId where the packages are installed. These are to be started with a different executable. It is aimed for development of custom development environments, either for a specific language or a specific scenario. The Integrated mode installs the packages into the AppId of the Professional/Standard/Team System editions, so that the tools integrate into these editions.

The binary of the SQL Server Data Tools is devenv.exe typically found in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE.

image_thumb2

DevenvLocation_thumb1

SSIS Deployment model in 2012

To give an explanation as to why I decided to use the Project Deployment model with EncryptSensitiveWithPassword as the protection level, I will briefly describe it here. I will cover the topic at a greater depth in a later series.

Project Deployment Model

The 2012 version of Integration Services supports two deployment models: the Project Deployment model and the Package Deployment model. The Project Deployment model enables you to deploy your projects to the Integration Services server. The Project Deployment model has many benefits compared to the Package Deployment model. You can read Deployment of Projects and Packages and SSIS Package Deployment Model in SQL Server 2012 to get more information about the differences between the two deployment methods.

image_thumb5

If you build an SSIS project file using the project deployment model, a project deployment file will be created (.ispac extension). The project deployment file is a self-contained package that includes only essential information about the packages and parameters in the project. You can check it contents using a file archiver like 7zip.

image_thumb9

If you double click the created (.ispac) file, the Integration Service Deployment Wizard will be launched. The Integration Service Deployment Wizard has a command line interface (ISDeploymentWizard.exe).  You can get the created command in the summary screen.

image_thumb11

SSIS Catalog

The SSIS catalog is a new type of storage for SSIS. It’s a user database so you can query tables and easily backup/restore the whole repository. You may refer to SSIS Catalog and SSIS 2012 Configuration Guide – Part 1: Introduction for more information.

The SSISDB catalog is central to working with Integration Services (SSIS) projects that you’ve deployed to the Integration Services server.In an example case, you would need to set project and package parameters, configure environments to specify runtime values for packages, execute and troubleshoot packages, and manage Integration Services server operations.

image_thumb12

Security for SSIS Packages

To protect the data in an Integration Services package, you can set the protection level.

image_thumb13

Access Control for Sensitive Data in Packages give us an example of protection level settings based on the package life cycle.

Typically, you change the protection level as listed through the following steps as requirements change:

  1. During development, leave the protection level of packages set to the default value of EncryptSensitiveWithUserKey. This setting helps ensure that only the developer is able to see sensitive values in the package. You can also consider using EncryptAllWithUserKey, or DontSaveSensitive.
  2. When it is time to deploy your packages, the protection level should be changed to one that does not depend on the developer’s user key. Therefore you would typically have to select EncryptSensitiveWithPassword, or EncryptAllWithPassword. Encrypt the packages by assigning a temporary strong password that is also known to the operations team for the production environment.
  3. After the packages have been deployed to the production environment, the operations team can re-encrypt the deployed packages by assigning a strong password that is known only to them. Alternatively, they can encrypt the deployed packages by selecting EncryptSensitiveWithUserKey orEncryptAllWithUserKey and using the local credentials of the account that will run the packages.

Command line build of SSIS packages

You may assume that MSBuild will be able to support an SSIS project file (..dtproj extension) by default, though this is not the case. You may see the following error message when attempting to build.

image_thumb15

DEVENV

As I have mentioned earlier, SSDT functionality can be utilized by running devenv.exe, which also provides access to a command line interface. You may refer to Devenv Command Line Switches for the available options. Building using devenv.exe works fine as long as your project’s protection level is not EncryptSensitiveWithPassword, or EncryptAllWithPassword. You can get devenv.exe by installing SQL Data Tools from the SQL2012.ISO. Just a note, The free SSDT tools from the web don’t have BI functionality. You can read Richard Fennell’s Getting SQL 2012 SSIS packages built on TFS 2012.2 for additional information.

D:\App_temp\SSIS\DeployDemo>”C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv” DeployDemo.sln /build “Development|Default”

Microsoft (R) Visual Studio Version 10.0.40219.1.
Copyright (C) Microsoft Corp. All rights reserved.
—— Build started: Project: DeployDemo, Configuration: Development ——
Build started: SQL Server Integration Services project: Incremental …
Starting project consistency check …
Project consistency check completed. The project is consistent.
File ‘D:\App_temp\SSIS\DeployDemo\DeployDemo\obj\Development\DeployDemo.dtproj’get updated.
File ‘D:\App_temp\SSIS\DeployDemo\DeployDemo\obj\Development\Project.params’ get updated.
File ‘D:\App_temp\SSIS\DeployDemo\DeployDemo\obj\Development\LEN-062_JY2012.nxa_repository.conmgr’ get updated.
Applied active configuration to ‘Project.params’.
Applied active configuration to ‘Package.dtsx’.
DeployDemo -> D:\App_temp\SSIS\DeployDemo\DeployDemo\bin\Development\DeployDemo.ispac
Build complete — 0 errors, 0 warnings
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

However, if you change the protection level to either EncryptSensitiveWithPassword or EncryptAllWithPassword, a window will pop up and ask you to enter the protection password. There’s no switch that allows you to provide a password from the command line.

image_thumb19

It was due to this issue that I explored using MSBuild for the build process.

MSBuild

It’s important to know what MSBuild is in order to understand how the new solution works. Let’s read the description from MSDN’s MSBuild page:

The Microsoft Build Engine is a platform for building applications. This engine, which is also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software. Visual Studio uses MSBuild, but it doesn’t depend on Visual Studio. By invoking msbuild.exe on your project or solution file, you can orchestrate and build products in environments where Visual Studio isn’t installed.

Visual Studio uses MSBuild to load and build managed projects. The project files in Visual Studio (.csproj, .vbproj, .vcxproj, and others) contain MSBuild XML code that executes when you build a project by using the IDE. Visual Studio projects import all the necessary settings and build processes to do typical development work, but you can extend or modify them from within Visual Studio or by using an XML editor.

In short MSBuild uses an XML-based project file format to retrieve the necessary configuration:

MSBuild.exe MyProj.proj /property:Configuration=Debug

You may consider reading Walkthrough: Creating an MSBuild Project File from Scratch to understand more about the MSBuild Project file (AKA MSBuild script). The error message I got when I tried to build an SSIS project file (.dtproj extension) earlier indicated that the XML format of an SSIS project file is not recognized by MSBuild.

SSISMSBuild and MSBuild script

There’s a codeplex project (Microsoft SQL Server Community Samples: Integration Services) where you can create Microsoft.SqlServer.IntegrationServices.Build.dll. You can also get an MSBuild script that links Microsoft.SqlServer.IntegrationServices.Build.dll from here: msbuild script for building and deploying a SSIS .ispac file. Below is the MSBuild script from that link.

<?xml version="1.0" encoding="Windows-1252"?>
<Project  xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
          DefaultTargets="SSISBuild;SSISDeploy">
  <!--Requires a property called $(SSISProj) to be defined when this script is called-->
  <UsingTask TaskName="DeploymentFileCompilerTask" AssemblyFile="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.SqlServer.IntegrationServices.Build.dll" />
  <Target Name="SSISBuild" Condition="'$(SSISProj)' != ''">
    <PropertyGroup>
      <SSISProjPath>..\$(SSISProj)\$(SSISProj).dtproj</SSISProjPath>
    </PropertyGroup>
    <Message Text="**************Building SSIS project: $(SSISProjPath) for configuration: $(CONFIGURATION)**************" />
    <DeploymentFileCompilerTask
      InputProject="$(SSISProjPath)"
      Configuration="$(CONFIGURATION)"
      ProtectionLevel="DontSaveSensitive">
    </DeploymentFileCompilerTask>
  </Target>

  <UsingTask TaskName="DeployProjectToCatalogTask" AssemblyFile="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.SqlServer.IntegrationServices.Build.dll" />
  <Target Name="SSISDeploy" Condition="'$(SSISProj)' != ''">
    <Message Text="**************Publishing SSIS project: $(SSISProj) to: $(SSISServer) to folder: $(PROJECTNAME)**************" />
    <PropertyGroup>
      <ISPac>..\$(SSISProj)\bin\$(CONFIGURATION)\$(SSISProj).ispac</ISPac>
    </PropertyGroup>
    <DeployProjectToCatalogTask
          DeploymentFile="$(ISPac)"
          Instance="$(SSISServer)"
          Folder="$(PROJECTNAME)"
          CreateFolder="true"/>
  </Target>
</Project>

This MSBuild script performs two functions: SSISBuild and SSISDeploy. I saved the code to a file called “SSIS.MSBuild.proj” and executed MSBuild.exe illustrated below.

D:\App_temp\SSIS\DeployDemo\DeployDemo>MSBuild SSIS.MSBuild.proj /t:SSISBuild,SSISDeploy /p:SSISProj=”DeployDemo”,Configuration=”Development”,ProtectionLevel=”EncryptSensitiveWithPassword”,ProjectPassword=”1234″,SSISServer=”LEN-062\JY2012″,ProjectName=”DeployDemo”

image_thumb21

How to build Microsoft.SqlServer.IntegrationServices.Build.dll

I will explain how to compile Microsoft.SqlServer.IntegrationServices.Build.dll using the source code from the codeplex project (Microsoft SQL Server Community Samples: Integration Services). I’d like to mention the small challenges that I faced while trying to compile the source code.

  1. Prerequisites: The following should be installed on a machine that you are going to use.
    1. MS SQL Server 2012
    2. Visual studio 2010
  2. Download source code
    http://sqlsrvintegrationsrv.codeplex.com/SourceControl/latest
    image_thumb23
  3. Unzip downloaded file
  4. Go to SSISMSBuild project folder (sqlsrvintegrationsrv-100610\main\SSISMSBuild).
    There are two projects under SSISMDBuild, 2008 and Project. Project is for 2012 is C:\sqlsrvintegrationsrv-100610\main\SSISMSBuild\Project
    SSIS Junkie mentioned SSISMSBuild is included in MSBuild extension pack. However, that integration is done only for a 2008 project.
  5. Reference hint path modification
    Open C:\sqlsrvintegrationsrv-100610\main\SSISMSBuild\Project\Microsoft.SqlServer.IntegrationServices.Build.csproj from the text editor.image_thumb26Change the highlighted part to full path.image_thumb29
  6. Open C:\sqlsrvintegrationsrv-100610\main\SSISMSBuild\Project\Microsoft.SqlServer.IntegrationServices.Build.csproj using visual studio.
    If you try to compile it, it will generate an error due to a missing key file. You can see the following line from the project file.
    image_thumb30
  7. Sign an AssemblyWith the project node selected in Solution Explorer, from the Project menu, click Properties (or right-click the project node in Solution Explorer, and click Properties). In the Project Designer, click the Signing tab. Then you will see the following screen.
  8. Choose new and provide file name and uncheck Protect my key file with a password.

    Check Signing an Assembly in Visual Studio for more details
  9. Compile
  10. Copy created Microsoft.SqlServer.IntegrationServices.Build.dll file to the following folder
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies

Summary

It took me quite a while to figure this out and I hope this can save you time when setting up an automated build process using MSBuild. I think it would be great if MSBuild adds support for SSIS projects by default in the future.

Posted in SQL SERVER, SSIS | Tagged: , , , , , , , , , | 49 Comments »