当其中一个单元格必须接受超过255个字符的值时,如何从SQL Server加载Excel中的数据

时间:2021-05-26 10:20:22

I know it's a common issue, but I still didn't find a solution. I need to export data from SQL Server 2012 to an Excel destination using SSIS.

我知道这是一个常见的问题,但我仍然没有找到解决方案。我需要使用SSIS将数据从SQL Server 2012导出到Excel目标。

当其中一个单元格必须接受超过255个字符的值时,如何从SQL Server加载Excel中的数据

The value of one of the columns is going to be more that 255 characters long, so the cell in Excel has to accept more than 255 characters as well.

其中一列的值将超过255个字符,因此Excel中的单元格也必须接受超过255个字符。

That's why I got an error.

这就是我收到错误的原因。

I changed the registry key to 0, but it still doesn't work.

我将注册表项更改为0,但它仍然无法正常工作。

当其中一个单元格必须接受超过255个字符的值时,如何从SQL Server加载Excel中的数据

I tried to create a dummy column in Excel, but the data looks weird.

我试图在Excel中创建一个虚拟列,但数据看起来很奇怪。

Are there any other solutions that I am not aware of?

还有其他我不知道的解决方案吗?

1 个解决方案

#1


0  

This is what I usually do as a workaround in such cases.

这就是我通常在这种情况下作为解决方法所做的事情。

I try to use SQL query as source, so this may work only in that case. So assuming you are picking up data from a view or table (say tbl)

我尝试使用SQL查询作为源,因此这可能仅适用于该情况。假设您从视图或表中获取数据(比如tbl)

so instead of

而不是

select ID,Name,DetailDescription from tbl

do (assuming DetailDescription is the column which can contain huge data)

do(假设DetailDescription是可以包含大量数据的列)

select 
   ID =NULL, 
   Name= N'', 
   DetailDescription =REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(N'__________','_','_____'),'_','_____'),'_','_____'),'_','_____'),'_','_____')
 union
select ID,Name,DetailDescription from tbl

#1


0  

This is what I usually do as a workaround in such cases.

这就是我通常在这种情况下作为解决方法所做的事情。

I try to use SQL query as source, so this may work only in that case. So assuming you are picking up data from a view or table (say tbl)

我尝试使用SQL查询作为源,因此这可能仅适用于该情况。假设您从视图或表中获取数据(比如tbl)

so instead of

而不是

select ID,Name,DetailDescription from tbl

do (assuming DetailDescription is the column which can contain huge data)

do(假设DetailDescription是可以包含大量数据的列)

select 
   ID =NULL, 
   Name= N'', 
   DetailDescription =REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(N'__________','_','_____'),'_','_____'),'_','_____'),'_','_____'),'_','_____')
 union
select ID,Name,DetailDescription from tbl