{"id":361,"date":"2013-10-21T14:35:04","date_gmt":"2013-10-21T19:35:04","guid":{"rendered":"http:\/\/www.sqlfreelancer.com\/blog\/?p=361"},"modified":"2014-03-07T14:48:04","modified_gmt":"2014-03-07T20:48:04","slug":"sql-server-integration-services-data-type-conversion-testing","status":"publish","type":"post","link":"https:\/\/www.sqlfreelancer.com\/blog\/sql-server-integration-services-data-type-conversion-testing\/","title":{"rendered":"SQL Server Integration Services Data Type Conversion Testing"},"content":{"rendered":"<p>There are two ways of converting data types within SQL Server Integration Services (SSIS).\u00a0 Here is an overview of those options:<\/p>\n<ul>\n<li>One way is using T-SQL code. Using the CAST function in your code can convert one data type into another. The scope of this tip is not intended on going into detail about the CAST function, but I will show a quick example.<\/li>\n<li>The second way is using the Data Conversion Transformation Task. This task will convert the data in an input column to a different data type and then copy it to the output column. The task itself isn&#8217;t too complicating to setup as I&#8217;ll show you in this tip.<\/li>\n<\/ul>\n<h2>SQL Server Integration Services Data Conversion Task to Convert Data Types<\/h2>\n<p>Let&#8217;s look at the Data Conversion task first&#8230;<\/p>\n<p>First, open Visual Studio (or Business Intelligence Dev Studio if you&#8217;re using pre SQL Server 2012) and create an SSIS project. Next, we can go ahead and configure a Connection Manager to our database. Right click Connection Managers in Solution Explorer and choose New Connection Manager:<\/p>\n<p><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-362\" alt=\"SQL Freelancer SQL Server SSIS Data Type Conversion\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion.png\" width=\"453\" height=\"183\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion.png 453w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-300x121.png 300w\" sizes=\"auto, (max-width: 453px) 100vw, 453px\" \/><\/a><br \/>\nChoose your Connection Manager type. In this example, we&#8217;ll use OLEDB. Next, configure the Connection Manager to point to your dataset. In this example, I&#8217;ll use localhost and the AdventureWorks2008R2 database:<br \/>\n<a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-363\" alt=\"SQL Freelancer SQL Server SSIS Data Type Conversion\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-1.png\" width=\"601\" height=\"599\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-1.png 601w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-1-150x150.png 150w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-1-300x300.png 300w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/a><br \/>\nTest the connection and click OK. Next, drag a Data Flow task from the SSIS toolbox onto the design screen:<\/p>\n<p><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-364\" alt=\"SQL Freelancer SQL Server SSIS Data Type Conversion\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-2.png\" width=\"624\" height=\"337\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-2.png 624w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-2-300x162.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><br \/>\n<\/a>Right click the Data Flow task and choose Edit. You are now inside the data flow task. This is where all the action happens. Drag an OLEDB source task from the SSIS toolbox to the design screen:<\/p>\n<p><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-365\" alt=\"SQL Freelancer SQL Server SSIS Data Type Conversion\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-3.png\" width=\"482\" height=\"434\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-3.png 482w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-3-300x270.png 300w\" sizes=\"auto, (max-width: 482px) 100vw, 482px\" \/><\/a><br \/>\nRight click the OLEDB task and choose Edit. This screen is where we will define the Connection Manager we created earlier. Under OLEDB connection manager choose the connection you created. Leave data access mode as Table or view. Change the name of the table or the view to the table that contains the data types to change. In this example, I&#8217;ll use a table named Sales.CurrencyRate:<\/p>\n<p><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-366\" alt=\"SQL Freelancer SQL Server SSIS Data Type Conversion\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-4.png\" width=\"624\" height=\"479\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-4.png 624w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-4-300x230.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><br \/>\n<\/a>To preview the data click Preview. In my example, I want to change the CurrencyRateDate and the ModifiedDate columns from a datetime data type to a date data type:<\/p>\n<p><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-367\" alt=\"SQL Freelancer SQL Server SSIS Data Type Conversion\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-5.png\" width=\"616\" height=\"469\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-5.png 616w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-5-300x228.png 300w\" sizes=\"auto, (max-width: 616px) 100vw, 616px\" \/><\/a><br \/>\nClick OK to close the OLEDB Source task. Drag the Data Conversion Transformation task onto the design screen. Connect the OLEDB Source task to the Data Conversion task:<\/p>\n<p><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-368\" alt=\"SQL Freelancer SQL Server SSIS Data Type Conversion\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-6.png\" width=\"536\" height=\"332\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-6.png 536w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-6-300x185.png 300w\" sizes=\"auto, (max-width: 536px) 100vw, 536px\" \/><br \/>\n<\/a>Right click the Data Conversion task and choose Edit. Here is where we will convert our data types. Since I am converting CurrencyRateDate and ModifiedDate I will click on each of them in the Available Input Columns list:<\/p>\n<p><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-369\" alt=\"SQL Freelancer SQL Server SSIS Data Type Conversion\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-7.png\" width=\"624\" height=\"355\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-7.png 624w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2014\/03\/SQL-Server-SSIS-Data-Type-Conversion-7-300x170.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.mssqltips.com\/sqlservertip\/3046\/sql-server-integration-services-data-type-conversion-testing\/\" target=\"_blank\">Click here to view the rest of this post.<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are two ways of converting data types within SQL Server Integration Services (SSIS).\u00a0 Here is an overview of those options: One way is using T-SQL code. Using the CAST function in your code can convert one data type into another. The scope of this tip is not intended on going into detail about the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49,8],"tags":[81,97,83,50,57],"class_list":["post-361","post","type-post","status-publish","format-standard","hentry","category-integration-services-ssis","category-performance-tuning","tag-data-flow","tag-performance-tuning","tag-sql-server-business-intelligence","tag-ssis","tag-tuning"],"_links":{"self":[{"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/posts\/361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/comments?post=361"}],"version-history":[{"count":1,"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/posts\/361\/revisions"}],"predecessor-version":[{"id":370,"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/posts\/361\/revisions\/370"}],"wp:attachment":[{"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/media?parent=361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/categories?post=361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/tags?post=361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}