Sql server “源数据类型”;200“;将查询结果导出到excel Microsoft SQL Server 2012时未找到错误

Sql server “源数据类型”;200“;将查询结果导出到excel Microsoft SQL Server 2012时未找到错误,sql-server,excel,ssis,sql-server-2012,ssms,Sql Server,Excel,Ssis,Sql Server 2012,Ssms,我对Microsoft SQL Server非常陌生,正在使用2012 Management Studio。当我尝试使用向导将查询结果导出到excel文件时,出现上述错误。我在其他地方看到了针对此错误的解决方案,但我不知道如何实现建议的解决方案。有人能一步一步地告诉我这些解决方案吗 我认为我的问题是SQL Server导入和导出向导无法识别Varchar和NVarchar,我认为这是我收到错误的列的数据类型 查询: SELECT licenseEntitlement.entID, l

我对Microsoft SQL Server非常陌生,正在使用2012 Management Studio。当我尝试使用向导将查询结果导出到excel文件时,出现上述错误。我在其他地方看到了针对此错误的解决方案,但我不知道如何实现建议的解决方案。有人能一步一步地告诉我这些解决方案吗

我认为我的问题是SQL Server导入和导出向导无法识别Varchar和NVarchar,我认为这是我收到错误的列的数据类型

查询:

SELECT     licenseEntitlement.entID, licenseEntitlement.entStartDate, entEndDate, quote.quoteId, quote.accountId, quote.clientId, quote.clientName, quote.contactName, 
                      quote.contactEmail, quote.extReference, quote.purchaseOrderNumber, quote.linkedTicket
FROM         licenseEntitlement INNER JOIN
                      quote ON quote.quoteId = SUBSTRING(licenseEntitlement.entComments, 12, PATINDEX('% Created%', licenseEntitlement.entComments) - 12)
inner join sophos521.dbo.computersanddeletedcomputers on computersanddeletedcomputers.name = entid and IsNumeric(computersanddeletedcomputers.name) = 1
WHERE     (licenseEntitlement.entType = 'AVS') AND (licenseEntitlement.entComments LIKE 'OV Order + %') and entenddate < '4/1/2014' 
ORDER BY licenseEntitlement.entEndDate

如果需要更多详细信息,请让我知道

因此,在StackOverflow链接上执行您提出的建议,将查询转换为
视图
,下面是一个可能的示例(带有一些代码格式;)--

然后,您当然会从表
zz\u LIC\u ENT\u DETAIL
(或您选择的任何表名)导出


希望对您有所帮助……

右键单击“查询结果”窗口并选择“结果另存为”(CSV)可能会更容易

要在第一行中追加列名,还需要以这种方式修改查询(注意int或datetime列的转换):


我认为您需要显示您运行的查询,描述返回列的数据类型,描述导出结果所采取的步骤以及得到的错误。这里没有人会做你想做的事-如果我不能在5分钟内回答,我可能不会,除非我个人感兴趣-我们没有人会为此获得报酬,你的问题要求付出大量的努力,没有明确的限制。SSIS标签已经添加:Mgmt Studio中的导出数据向导正在运行
SSIS
(SQL Server集成工作室),这是一个SSIS错误。Simon是对的,但是:我们需要更多的细节。我建议从给我们错误消息的完整和准确文本开始。而且,由于
数据类型
是列的属性,请告诉我们关于列的内容。感谢您的回复,我添加了详细信息。我认为有一个简单的方法可以解决这个问题由于我在这里的知识有限,我们将用简单的术语进行解释,这些术语不太专业。如果不是这样,请告诉我,我可以删除该问题。再次感谢。首先,Microsoft承认这是导入/导出向导中的已知错误。其次,建议所有链接中的解决方法是将您的查询转换为一个视图,然后从中导出。为什么您不能实现它?注意:如果您正在处理数百万行,这将不起作用
TITLE: SQL Server Import and Export Wizard
------------------------------

Column information for the source and the destination data could not be retrieved, or the data types of source columns were not mapped correctly to those available on the destination provider.


[Query] -> `Query`:

          - Column "accountId": Source data type "200" was not found in the data type mapping file.
          - Column "clientId": Source data type "200" was not found in the data type mapping file.
          - Column "clientName": Source data type "200" was not found in the data type mapping file.
          - Column "contactName": Source data type "200" was not found in the data type mapping file.
          - Column "contactEmail": Source data type "200" was not found in the data type mapping file.
          - Column "extReference": Source data type "200" was not found in the data type mapping file.
          - Column "purchaseOrderNumber": Source data type "200" was not found in the data type mapping file.
          - Column "linkedTicket": Source data type "200" was not found in the data type mapping file.
CREATE VIEW [dbo].[test__View_1]
AS
SELECT LIC.entID, LIC.entStartDate, entEndDate, 
    quote.quoteId, quote.accountId, quote.clientId, quote.clientName, 
    quote.contactName, quote.contactEmail, quote.extReference, 
    quote.purchaseOrderNumber, quote.linkedTicket
FROM [dbo].licenseEntitlement  LIC  WITH(NOLOCK)
    INNER JOIN [dbo].quote  WITH(NOLOCK)
        ON quote.quoteId = SUBSTRING(LIC.entComments, 12, 
            PATINDEX('% Created%', LIC.entComments) - 12)
    INNER JOIN sophos521.dbo.computersanddeletedcomputers  COMPS  WITH(NOLOCK)
        ON COMPS.name = entid and IsNumeric(COMPS.name) = 1
WHERE (LIC.entType = 'AVS') 
  AND (LIC.entComments LIKE 'OV Order + %') 
  and (entenddate < '4/1/2014')
ORDER BY LIC.entEndDate

GO
IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES
            WHERE TABLE_NAME = 'zz_LIC_ENT_DETAIL')
    DROP TABLE [dbo].zz_LIC_ENT_DETAIL

SELECT LIC.entID, LIC.entStartDate, LIC.entEndDate, 
    quote.quoteId, quote.accountId, quote.clientId, quote.clientName, 
    quote.contactName, quote.contactEmail, quote.extReference, 
    quote.purchaseOrderNumber, quote.linkedTicket
INTO [dbo].zz_LIC_ENT_DETAIL
FROM [dbo].licenseEntitlement  LIC  WITH(NOLOCK)
    INNER JOIN [dbo].quote  WITH(NOLOCK)
        ON quote.quoteId = SUBSTRING(LIC.entComments, 12, 
            PATINDEX('% Created%', LIC.entComments) - 12)
    INNER JOIN sophos521.dbo.computersanddeletedcomputers  COMPS  WITH(NOLOCK)
        ON COMPS.name = LIC.entid and IsNumeric(COMPS.name) = 1
WHERE (LIC.entType = 'AVS') 
  AND (LIC.entComments LIKE 'OV Order%') 
  and (LIC.entenddate < '4/1/2014')
ORDER BY LIC.entEndDate
select 'col1', 'col2', 'col3'
union all
select cast(id as varchar(10)), name, cast(someinfo as varchar(28))
from Question1355876