You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SSIS执行SQL任务报错:查询解析失败,包执行终止求助

Fixing SSIS Execute SQL Task Error for Audit Insert

Let's walk through the most common issues that would cause your audit insert to fail, and how to fix them:

1. Fix the Typo in Your SQL Statement

First off, I spotted a spelling mistake in your INSERT query:
PacakgeVersion should be PackageVersion (you're missing a "k"). This is a classic gotcha—SQL will throw an error if the column name doesn't match exactly what's in your AuditInfo table.

Update your query to:

insert into AuditInfo ( PackageName , PackageId , PackageVersion , StartTime , WorkflowStatus , rowcounts ) 
values ( ?,?,?,?,?,? )

2. Verify Parameter Mapping (Critical for SSIS)

SSIS uses positional mapping for ? placeholders—meaning the first ? maps to the first entry in your Parameter Mapping list, the second ? to the second, and so on. Double-check these details:

  • Count & Order: You have 6 placeholders, so you need exactly 6 parameter mappings, ordered to match the columns in your INSERT statement (PackageName → first ?, PackageId → second, etc.).
  • Data Type Matching: Ensure each variable's data type aligns with the AuditInfo table's columns:
    • PackageName/PackageVersion/WorkflowStatus: Use string types (NVARCHAR/VARCHAR)
    • PackageId: Map to a UNIQUEIDENTIFIER type (matches SSIS's System::PackageID system variable)
    • StartTime: Use DATETIME/DATETIME2 (matches System::StartTime)
    • rowcounts: Use INT/BIGINT (match your row count variable's type)
  • Variable Scope: Make sure the system/user variables you're referencing are accessible to the Execute SQL Task (e.g., if a variable is defined in a parent container, the task needs permission to access it).

3. Validate Connection Manager Settings

  • Confirm your connection manager is pointing to the correct database instance and database where AuditInfo lives.
  • Test the connection using the "Test Connection" button in the connection manager editor to rule out connectivity issues.

4. Check Database Permissions

The account running your SSIS package needs INSERT permissions on the AuditInfo table. To test this:

  • Log into the database using the same credentials from your connection manager.
  • Run your corrected INSERT query manually (replace the ? with sample values). If this fails, you'll know it's a permission issue to fix with your DBA.

5. Enable Detailed Logging for More Clarity

If you're still stuck, turn on SSIS logging to capture the full error message:

  • Go to the SSIS menu → Logging.
  • Select your Execute SQL Task and enable logging for the "OnError" event.
  • Run the package again—you'll get a specific error (like "invalid column name" or "data type mismatch") that points directly to the problem.

内容的提问来源于stack exchange,提问作者Abhijit Kaware

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:20:10