SSIS Import Excel to SQL Truncation Issues











up vote
0
down vote

favorite












I'm using SSIS 2012 and SQL Server 2014. I've had this issue forever and have YET to see a viable solution - and I'm not sure why more people don't experience this issue. Here is my simple data flow task:



enter image description here



I receive numerous Excel files from clients. The problem is that some of the fields contain text that is greater than 255 characters - and as we all know Microsoft is NOT smart enough to read all rows (the first 8 records are read and assumes that if the first 8 rows are less than 255 characters then ALL the rows must be less than 255).



Of course this leads to truncation errors. Even if I set my SQL destination column value to nvarchar(max), SSIS will still error out. As I'm sure many have experienced simply using SSMS and importing an Excel file manually will generate this error. For my SSIS package, I have a data conversion task that supposedly converts the source data to a format that can then be brought into SQL Server. Apparently not.



Here is my simple data flow task with the offending column highlighted:



enter image description here



So, the limited solutions I've found online recommend sorting the data so that the widest text value is at the top so SQL Server can read it. I can't do this for hundreds of files each and every time. And I need the data in the original sort order, too, so that's not viable. Or I should insert a dummy record as the first row in the Excel file.



And how would this be done - in a script task? Again, over potentially hundreds of files? I've also heard I can change the registry somehow. Do I want to mess with that? Do any of these sound practical?



I have not seen anything online that's comparable to my situation - and I'm flummoxed. How can that be? I can't be the only one who experiences these types of truncation issues.



Anyway, I appreciate any and all help.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I'm using SSIS 2012 and SQL Server 2014. I've had this issue forever and have YET to see a viable solution - and I'm not sure why more people don't experience this issue. Here is my simple data flow task:



    enter image description here



    I receive numerous Excel files from clients. The problem is that some of the fields contain text that is greater than 255 characters - and as we all know Microsoft is NOT smart enough to read all rows (the first 8 records are read and assumes that if the first 8 rows are less than 255 characters then ALL the rows must be less than 255).



    Of course this leads to truncation errors. Even if I set my SQL destination column value to nvarchar(max), SSIS will still error out. As I'm sure many have experienced simply using SSMS and importing an Excel file manually will generate this error. For my SSIS package, I have a data conversion task that supposedly converts the source data to a format that can then be brought into SQL Server. Apparently not.



    Here is my simple data flow task with the offending column highlighted:



    enter image description here



    So, the limited solutions I've found online recommend sorting the data so that the widest text value is at the top so SQL Server can read it. I can't do this for hundreds of files each and every time. And I need the data in the original sort order, too, so that's not viable. Or I should insert a dummy record as the first row in the Excel file.



    And how would this be done - in a script task? Again, over potentially hundreds of files? I've also heard I can change the registry somehow. Do I want to mess with that? Do any of these sound practical?



    I have not seen anything online that's comparable to my situation - and I'm flummoxed. How can that be? I can't be the only one who experiences these types of truncation issues.



    Anyway, I appreciate any and all help.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm using SSIS 2012 and SQL Server 2014. I've had this issue forever and have YET to see a viable solution - and I'm not sure why more people don't experience this issue. Here is my simple data flow task:



      enter image description here



      I receive numerous Excel files from clients. The problem is that some of the fields contain text that is greater than 255 characters - and as we all know Microsoft is NOT smart enough to read all rows (the first 8 records are read and assumes that if the first 8 rows are less than 255 characters then ALL the rows must be less than 255).



      Of course this leads to truncation errors. Even if I set my SQL destination column value to nvarchar(max), SSIS will still error out. As I'm sure many have experienced simply using SSMS and importing an Excel file manually will generate this error. For my SSIS package, I have a data conversion task that supposedly converts the source data to a format that can then be brought into SQL Server. Apparently not.



      Here is my simple data flow task with the offending column highlighted:



      enter image description here



      So, the limited solutions I've found online recommend sorting the data so that the widest text value is at the top so SQL Server can read it. I can't do this for hundreds of files each and every time. And I need the data in the original sort order, too, so that's not viable. Or I should insert a dummy record as the first row in the Excel file.



      And how would this be done - in a script task? Again, over potentially hundreds of files? I've also heard I can change the registry somehow. Do I want to mess with that? Do any of these sound practical?



      I have not seen anything online that's comparable to my situation - and I'm flummoxed. How can that be? I can't be the only one who experiences these types of truncation issues.



      Anyway, I appreciate any and all help.










      share|improve this question















      I'm using SSIS 2012 and SQL Server 2014. I've had this issue forever and have YET to see a viable solution - and I'm not sure why more people don't experience this issue. Here is my simple data flow task:



      enter image description here



      I receive numerous Excel files from clients. The problem is that some of the fields contain text that is greater than 255 characters - and as we all know Microsoft is NOT smart enough to read all rows (the first 8 records are read and assumes that if the first 8 rows are less than 255 characters then ALL the rows must be less than 255).



      Of course this leads to truncation errors. Even if I set my SQL destination column value to nvarchar(max), SSIS will still error out. As I'm sure many have experienced simply using SSMS and importing an Excel file manually will generate this error. For my SSIS package, I have a data conversion task that supposedly converts the source data to a format that can then be brought into SQL Server. Apparently not.



      Here is my simple data flow task with the offending column highlighted:



      enter image description here



      So, the limited solutions I've found online recommend sorting the data so that the widest text value is at the top so SQL Server can read it. I can't do this for hundreds of files each and every time. And I need the data in the original sort order, too, so that's not viable. Or I should insert a dummy record as the first row in the Excel file.



      And how would this be done - in a script task? Again, over potentially hundreds of files? I've also heard I can change the registry somehow. Do I want to mess with that? Do any of these sound practical?



      I have not seen anything online that's comparable to my situation - and I'm flummoxed. How can that be? I can't be the only one who experiences these types of truncation issues.



      Anyway, I appreciate any and all help.







      sql sql-server excel ssis truncation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 8:29









      marc_s

      566k12610931245




      566k12610931245










      asked Nov 11 at 5:38









      Craig

      438




      438
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          Potential solutions:



          1- Change the sample size by updating TypeGuessRows in the registry key for HKEY_LOCAL_MACHINESOFTWAREMicrosoftJet4.0EnginesExcel. Path might not be exactly same in your machine but would be similar.



          2- Use Flat File Connection Manager instead of Excel Connection Manager, right click, go to Advanced Editor, go to Input and Output Properties tab, find your column on the left under Output Columns and set its length to 1000.



          enter image description here






          share|improve this answer





















          • a "flat file connection manager" - for an EXCEL file??! How's that supposed to work? I tried connecting to my Excel source file and the editor couldn't even recognize any columns. Could you back up a step and show/advise how this works? Thanks.
            – Craig
            Nov 11 at 6:26












          • You can convert the excel into csv first, i believe.
            – Eray Balkanli
            Nov 11 at 6:27










          • Again, for potentially hundreds of files? What if the data has embedded commas? I appreciate the help but my experience with CSV files has been even more nightmarish.
            – Craig
            Nov 11 at 6:29


















          up vote
          0
          down vote













          As a result of my own frustration with SSMS's inadequate diagnosis of data types in imported data, I wrote a tool to do the job instead. It works better for me; it might work better for you, if you're open to scripting solutions outside of the Microsoft environment. The tool is a Python script, available at https://pypi.org/project/execsql/. The IMPORT command will read an entire Excel or CSV file to determine data types, pretty much guaranteeing that the data will be imported successfully. Import from CSV is much faster than import from Excel, and line breaks inside columns of the CSV file are handled correctly.






          share|improve this answer





















          • Thank you. i will explore this option.
            – Craig
            Nov 12 at 17:19











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246142%2fssis-import-excel-to-sql-truncation-issues%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Potential solutions:



          1- Change the sample size by updating TypeGuessRows in the registry key for HKEY_LOCAL_MACHINESOFTWAREMicrosoftJet4.0EnginesExcel. Path might not be exactly same in your machine but would be similar.



          2- Use Flat File Connection Manager instead of Excel Connection Manager, right click, go to Advanced Editor, go to Input and Output Properties tab, find your column on the left under Output Columns and set its length to 1000.



          enter image description here






          share|improve this answer





















          • a "flat file connection manager" - for an EXCEL file??! How's that supposed to work? I tried connecting to my Excel source file and the editor couldn't even recognize any columns. Could you back up a step and show/advise how this works? Thanks.
            – Craig
            Nov 11 at 6:26












          • You can convert the excel into csv first, i believe.
            – Eray Balkanli
            Nov 11 at 6:27










          • Again, for potentially hundreds of files? What if the data has embedded commas? I appreciate the help but my experience with CSV files has been even more nightmarish.
            – Craig
            Nov 11 at 6:29















          up vote
          0
          down vote













          Potential solutions:



          1- Change the sample size by updating TypeGuessRows in the registry key for HKEY_LOCAL_MACHINESOFTWAREMicrosoftJet4.0EnginesExcel. Path might not be exactly same in your machine but would be similar.



          2- Use Flat File Connection Manager instead of Excel Connection Manager, right click, go to Advanced Editor, go to Input and Output Properties tab, find your column on the left under Output Columns and set its length to 1000.



          enter image description here






          share|improve this answer





















          • a "flat file connection manager" - for an EXCEL file??! How's that supposed to work? I tried connecting to my Excel source file and the editor couldn't even recognize any columns. Could you back up a step and show/advise how this works? Thanks.
            – Craig
            Nov 11 at 6:26












          • You can convert the excel into csv first, i believe.
            – Eray Balkanli
            Nov 11 at 6:27










          • Again, for potentially hundreds of files? What if the data has embedded commas? I appreciate the help but my experience with CSV files has been even more nightmarish.
            – Craig
            Nov 11 at 6:29













          up vote
          0
          down vote










          up vote
          0
          down vote









          Potential solutions:



          1- Change the sample size by updating TypeGuessRows in the registry key for HKEY_LOCAL_MACHINESOFTWAREMicrosoftJet4.0EnginesExcel. Path might not be exactly same in your machine but would be similar.



          2- Use Flat File Connection Manager instead of Excel Connection Manager, right click, go to Advanced Editor, go to Input and Output Properties tab, find your column on the left under Output Columns and set its length to 1000.



          enter image description here






          share|improve this answer












          Potential solutions:



          1- Change the sample size by updating TypeGuessRows in the registry key for HKEY_LOCAL_MACHINESOFTWAREMicrosoftJet4.0EnginesExcel. Path might not be exactly same in your machine but would be similar.



          2- Use Flat File Connection Manager instead of Excel Connection Manager, right click, go to Advanced Editor, go to Input and Output Properties tab, find your column on the left under Output Columns and set its length to 1000.



          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 5:47









          Eray Balkanli

          3,85741943




          3,85741943












          • a "flat file connection manager" - for an EXCEL file??! How's that supposed to work? I tried connecting to my Excel source file and the editor couldn't even recognize any columns. Could you back up a step and show/advise how this works? Thanks.
            – Craig
            Nov 11 at 6:26












          • You can convert the excel into csv first, i believe.
            – Eray Balkanli
            Nov 11 at 6:27










          • Again, for potentially hundreds of files? What if the data has embedded commas? I appreciate the help but my experience with CSV files has been even more nightmarish.
            – Craig
            Nov 11 at 6:29


















          • a "flat file connection manager" - for an EXCEL file??! How's that supposed to work? I tried connecting to my Excel source file and the editor couldn't even recognize any columns. Could you back up a step and show/advise how this works? Thanks.
            – Craig
            Nov 11 at 6:26












          • You can convert the excel into csv first, i believe.
            – Eray Balkanli
            Nov 11 at 6:27










          • Again, for potentially hundreds of files? What if the data has embedded commas? I appreciate the help but my experience with CSV files has been even more nightmarish.
            – Craig
            Nov 11 at 6:29
















          a "flat file connection manager" - for an EXCEL file??! How's that supposed to work? I tried connecting to my Excel source file and the editor couldn't even recognize any columns. Could you back up a step and show/advise how this works? Thanks.
          – Craig
          Nov 11 at 6:26






          a "flat file connection manager" - for an EXCEL file??! How's that supposed to work? I tried connecting to my Excel source file and the editor couldn't even recognize any columns. Could you back up a step and show/advise how this works? Thanks.
          – Craig
          Nov 11 at 6:26














          You can convert the excel into csv first, i believe.
          – Eray Balkanli
          Nov 11 at 6:27




          You can convert the excel into csv first, i believe.
          – Eray Balkanli
          Nov 11 at 6:27












          Again, for potentially hundreds of files? What if the data has embedded commas? I appreciate the help but my experience with CSV files has been even more nightmarish.
          – Craig
          Nov 11 at 6:29




          Again, for potentially hundreds of files? What if the data has embedded commas? I appreciate the help but my experience with CSV files has been even more nightmarish.
          – Craig
          Nov 11 at 6:29












          up vote
          0
          down vote













          As a result of my own frustration with SSMS's inadequate diagnosis of data types in imported data, I wrote a tool to do the job instead. It works better for me; it might work better for you, if you're open to scripting solutions outside of the Microsoft environment. The tool is a Python script, available at https://pypi.org/project/execsql/. The IMPORT command will read an entire Excel or CSV file to determine data types, pretty much guaranteeing that the data will be imported successfully. Import from CSV is much faster than import from Excel, and line breaks inside columns of the CSV file are handled correctly.






          share|improve this answer





















          • Thank you. i will explore this option.
            – Craig
            Nov 12 at 17:19















          up vote
          0
          down vote













          As a result of my own frustration with SSMS's inadequate diagnosis of data types in imported data, I wrote a tool to do the job instead. It works better for me; it might work better for you, if you're open to scripting solutions outside of the Microsoft environment. The tool is a Python script, available at https://pypi.org/project/execsql/. The IMPORT command will read an entire Excel or CSV file to determine data types, pretty much guaranteeing that the data will be imported successfully. Import from CSV is much faster than import from Excel, and line breaks inside columns of the CSV file are handled correctly.






          share|improve this answer





















          • Thank you. i will explore this option.
            – Craig
            Nov 12 at 17:19













          up vote
          0
          down vote










          up vote
          0
          down vote









          As a result of my own frustration with SSMS's inadequate diagnosis of data types in imported data, I wrote a tool to do the job instead. It works better for me; it might work better for you, if you're open to scripting solutions outside of the Microsoft environment. The tool is a Python script, available at https://pypi.org/project/execsql/. The IMPORT command will read an entire Excel or CSV file to determine data types, pretty much guaranteeing that the data will be imported successfully. Import from CSV is much faster than import from Excel, and line breaks inside columns of the CSV file are handled correctly.






          share|improve this answer












          As a result of my own frustration with SSMS's inadequate diagnosis of data types in imported data, I wrote a tool to do the job instead. It works better for me; it might work better for you, if you're open to scripting solutions outside of the Microsoft environment. The tool is a Python script, available at https://pypi.org/project/execsql/. The IMPORT command will read an entire Excel or CSV file to determine data types, pretty much guaranteeing that the data will be imported successfully. Import from CSV is much faster than import from Excel, and line breaks inside columns of the CSV file are handled correctly.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 18:12









          rd_nielsen

          1,6152615




          1,6152615












          • Thank you. i will explore this option.
            – Craig
            Nov 12 at 17:19


















          • Thank you. i will explore this option.
            – Craig
            Nov 12 at 17:19
















          Thank you. i will explore this option.
          – Craig
          Nov 12 at 17:19




          Thank you. i will explore this option.
          – Craig
          Nov 12 at 17:19


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246142%2fssis-import-excel-to-sql-truncation-issues%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Full-time equivalent

          さくらももこ

          13 indicted, 8 arrested in Calif. drug cartel investigation