Getting the right results with bcp and DTS with multiple versions of SQL Server installed.

I was using SSIS for the first time on an instance the other day and came across this error when I executed a package

Package migration from version 3 to version 2 failed with error 0xC001700A. The version number in the package is not valid. The version number cannot be greater than current version number.

This was a pain and wasn’t something that I was expecting, however, the error message made sense – the package was being executed by the wrong version of the executable. Not impossible to believe as I had SQL 2005 and SQL 2008 installed. When I executed the SSIS package the wrong executable as being picked as the default application and was unable to carry on as it recognised the package was in a ‘future’ version.

There are a few ways around this;

  • specifying the full path to the executable
  • ensuring the 2008 version of the executable in in the PATH environment variable before the 2005 one.
  • renaming the 2005 executable to something that is not default.

I chose the 3rd option – to rename the SQL 2005 DTExec.exe file so that the package execution will find the file of the same name in the SQL 2008 installation location. I navigated to C:Program FilesMicrosoft SQL Server90DTSBinn and renamed the file to DTExec_2005.exe (*) and tried the package again. It failed with the same error. Not impressed. How was that happening?

Well, I was on a 64bit Windows(tm) installation and hadn’t realised that there are two copies of DTExec installed. The other file was in C:Program Files (x86)Microsoft SQL Server90DTSBinn. I renamed that and all was well.

If you come across this error then this may help you. While you are in the Microsoft SQL Server directories you may choose to also rename the bcp.exe file of older versions in a similar way so that the correct application can be called as needed.

(*) – Don’t rename any files in these locations without thinking about it seriously – any files/packages/processes/jobs that rely on DTExec.exe or bcp.exe may fail or give unexpected results if they are executed with a different version. As always – test, test, test.