I have a SQL Server stored procedure that executes correctly every time when run manually with EXEC
, but when it runs as part of an SSIS package, it fails with an error like this:
Executing the query "EXECUTE (ProcName) " failed with the following error:
"The OLE DB provider "SQLNCLI10" for linked server "(OtherServer)" reported a
change in schema version between compile time ("177833127975044") and
run time ("177841717910098") for table (Server.Database.Schema.Table)".
The procedure is a MERGE
statement that merges data from a view into a table in another database on the same server as the SP.
The view refers to the linked server OtherServer
. The database referenced on the linked server is dropped and re-created on a nightly basis.
So far, I've tried these things:
1) Dropping and re-creating the view before running the MERGE.
2) Defining the SP that contains the MERGE WITH RECOMPILE
.
3) Wrapping the MERGE statement in EXEC()
so it wouldn't be compiled in advance.
4) Setting Bypass Prepare
to true on the relevant step in SSIS.
Edit:
The server with the stored procedure is running SQL Server 2008. The linked server is 2008 R2.