SSIS执行SQL任务报错:查询解析失败,包执行终止求助
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
AuditInfotable's columns:PackageName/PackageVersion/WorkflowStatus: Use string types (NVARCHAR/VARCHAR)PackageId: Map to a UNIQUEIDENTIFIER type (matches SSIS'sSystem::PackageIDsystem variable)StartTime: Use DATETIME/DATETIME2 (matchesSystem::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
AuditInfolives. - 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

