从Biztalk中执行存储过程时的SQL异常

时间:2015-08-03 09:58:05

标签: sql-server ssis biztalk

我们有一个存储过程,用于创建新的SSIS执行并启动它:

Declare @execution_id bigint

EXEC [SSISDB].[catalog].[create_execution] 
    @package_name=N'00 XXXX.dtsx', 
    @execution_id=@execution_id OUTPUT, 
    @folder_name=N'XX', 
    @project_name=N'XXX';

EXEC [SSISDB].[catalog].[start_execution] @execution_id;

当我们使用SQL Server Management Studio调用此存储过程时,这非常有效。但是,当我们从BizTalk(作为BTS服务帐户用户)执行此存储过程时,我们收到此错误:

  

System.Data.SqlClient.SqlException(0x80131904):' - '附近的语法不正确。
  ' - '附近的语法不正确。
  “ - ”附近的语法不正确。

     

服务器堆栈跟踪:
  在System.Runtime.AsyncResult.End [TAsyncResult](IAsyncResult结果)
  在System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
  at System.ServiceModel.Channels.ServiceChannel.EndCall(String action,Object [] outs,IAsyncResult results)
  在System.ServiceModel.Channels.ServiceChannel.EndRequest(IAsyncResult result)

     

在[0]处重新抛出异常:
  在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)
  在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 type)
  在System.ServiceModel.Channels.IRequestChannel.EndRequest(IAsyncResult结果)
  在Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result)

我们从BTS到MS SQL使用的模式:

<?xml version="1.0" encoding="utf-16"?>
<schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:ns0="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo" version="1.0" xmlns="http://www.w3.org/2001/XMLSchema">
  <annotation>
    <appinfo>
      <fileNameHint xmlns="http://schemas.microsoft.com/servicemodel/adapters/metadata/xsd">TypedProcedure.dbo</fileNameHint>
    </appinfo>
  </annotation>
  <element name="StartBifImport">
    <annotation>
      <documentation>
        <doc:action xmlns:doc="http://schemas.microsoft.com/servicemodel/adapters/metadata/documentation">TypedProcedure/dbo/StartBifImport</doc:action>
      </documentation>
    </annotation>
    <complexType>
      <sequence />
    </complexType>
  </element>
</schema>

BTS服务帐户在存储过程所在的数据库中具有db_owner角色,并且我们已明确地为SSIS文件夹和SSIS包提供了所有“grant”权限。

我们可以在执行表中看到没有创建任何执行,因此在该调用中似乎出现了问题。当与SQL事件探查器连接时,我们会看到返回相同的错误,但没有更多关于错误的进一步上下文;离开是没有多少痕迹。

有关如何调试或解决此问题的任何指示/想法?

2 个答案:

答案 0 :(得分:1)

我建议不要使用“强类型过程”模式,而应使用“过程”模式。 WCF-SQL适配器中的“强类型过程”存在记录的问题,即为其中包含临时表的存储过程生成模式。

SQL适配器不支持为其定义中包含临时表的强类型存储过程生成元数据。相反,您应该在使用Add Adapter Service Reference Plug-in或Consume Adapter Service Add-in时从Procedures节点生成相同过程的元数据。

可在此处找到更多信息:https://msdn.microsoft.com/en-us/library/dd788435(BTS.10).aspx#BKMK_SQLMetadataStronglyTyped

答案 1 :(得分:0)

创建一个简单的单向发送端口,它具有与忙于调试的过滤器相同的过滤器(和映射,如果适用),它只是写入文件。使用该文件的输出来确认发送到WCF-SQL适配器的消息具有预期的结构。

根据架构判断,它应该生成一个包含以下内容的文件:

<ns0:StartBifImport xmlns:ns0="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo">
</ns0:StartBifImport>