<p>I have an SSIS package that exports data to a couple of Excel files for transfer to a third party. To get this to run as a scheduled job on a 64-bit server I understand that I need to set the step as a CmdExec type and call the 32-bit version of DTExec. But I don't seem to be able to get the command right to pass in the connection string for the Excel files.</p>

<p>So far I have this: </p>

<pre><code>DTExec.exe /SQL \PackageName /SERVER OUR2005SQLSERVER /CONNECTION 
LETTER_Excel_File;\""Provider=Microsoft.Jet.OLEDB.4.0";"Data 
Source=""C:\Temp\BaseFiles\LETTER.xls";"Extended Properties=
""Excel 8.0;HDR=Yes"" /MAXCONCURRENT " -1 " /CHECKPOINTING OFF /REPORTING E
</code></pre>

<p>This gives me the error: <strong><code>Option "Properties=Excel 8.0;HDR=Yes" is not valid.</code></strong></p>

<p>I've tried a few variations with the Quotation marks but have not been able to get it right yet.</p>

<p>Does anyone know how to fix this?</p>

<p><strong><code>UPDATE:</code></strong></p>

<p>Thanks for your help but I've decided to go with CSV files for now, as they seem to just work on the 64-bit version.</p>

[{'answer_id': 22093, 'author': 'Marek Grzenkowicz', 'author_id': 95, 'author_profile': 'https://Stackoverflow.com/users/95', 'pm_score': 2, 'selected': False, 'text': '<p>Unless it\'s a business requirement, I suggest you move the connection string from the command line to the package and use a package configuration to define the path to the Excel file (in order not to hard-code it). This will make it easier to maintain.</p>\n\n<ol>\n<li>Define a variable <em>@ExcelPath</em>.</li>\n<li>Use connection\'s <em>Expression</em> property to construct a connection string - an example: <code>"Data Source=" + @[User::FilePath]  + ";Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBASE IV;"</code></li>\n<li>Assign a value to <em>@ExcelPath</em> in the package configuration.</li>\n</ol>\n\n<hr>\n\n<p>Take a closer look at the connection string above. It\'s taken from a working package. I\'m not sure about this, but maybe you don\'t need any quotes at all (the ones above are only there because the expression editor requires them).</p>\n\n<hr>\n\n<p><a href="http://chopeen.blogspot.com/2007/04/importing-data-from-dbf-files-using.html" rel="nofollow noreferrer">I have also had some problems with SSIS on 64-bit SQL Server 2005.</a> That post from my blog does not answer your question, but it is somewhat related so I am posting the link.</p>\n'}, {'answer_id': 110617, 'author': 'Michael Entin', 'author_id': 19880, 'author_profile': 'https://Stackoverflow.com/users/19880', 'pm_score': 2, 'selected': False, 'text': "<p>There is no 64-bit Jet OLEDB provider, so you can't access Excel files from 64-bit SSIS.</p>\n\n<p>However, you can use 32-bit SSIS even on 64-bit server. It is already installed when you installed 64-bit version, and all you need to do is run the 32-bit DTEXEC.EXE - the one installed <code>Program Files (x86)\\Microsoft Sql Server\\90\\Dts\\Binn</code> (replace <strong>90</strong> with <strong>100</strong> if you are using SSIS 2008).</p>\n"}, {'answer_id': 378782, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>You can use an Excel connection in 64bit environment.\nGo to the package configuration properties.</p>\n\n<p>Debugging -> Debugging Options -> Run64BtRuntime -> change to False\nIn addition if you use SQL Agent go to the job step properties and then check the 32 bit runtime.</p>\n\n<p>note: this only applies to debugging within Visual Studio...</p>\n'}, {'answer_id': 774652, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>I kinda did what Dr Zim did but I copied the DTExec file <code>C:\\Program Files (x86)\\Microsoft SQL Server\\90\\DTS\\Binn\\DTExec.exe</code> to <code>C:\\Program Files\\Microsoft SQL Server\\90\\DTS\\Binn\\</code> folder but named the 32 bit one to DTExec32.exe</p>\n\n<p>then I was able to run my SSIS script through a stored proc:</p>\n\n<pre><code>set @params = \'/set \\package.variables[ImportFilename].Value;"\\"\' + @FileName + \'\\"" \'\nset @cmd =  \'dtexec32 /SQ "\' + @packagename + \' \' + @params + \'"\'\n--DECLARE @returncode int\nexec master..xp_cmdshell @cmd\n--exec @returncode = master..xp_cmdshell @cmd\n--select @returncode\n</code></pre>\n'}, {'answer_id': 6805514, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<p>This step-by-step example is for others who might stumble upon this question. This example uses <em>SSIS 2005</em> and uses <em>SQL Server 2005 64-bit edition server</em> to run the job.</p>\n\n<p>The answer here concentrates only on fixing the error message mentioned in the question. The example will demonstrate the steps to recreate the issue and also the cause of the issue followed by how to fix it.</p>\n\n<p><strong><code>NOTE:</code></strong> I would recommend using the option of storing the package configuration values in database or using indirect XML configuration with the help of Environment Variables. Also, the steps to create Excel file would be done using a template which would then archived by moving to a different folder. These steps are not discussed in this post. As mentioned earlier, the purpose of this post is to address the error.</p>\n\n<p>Let’s proceed with the example. I have also blogged about this answer, which can be found in <a href="http://learnbycoding.com/2011/07/accessing-excel-data-source-from-an-ssis-package-that-is-deployed-on-a-64-bit-server/" rel="nofollow noreferrer">this link</a>. It is the same answer.</p>\n\n<p>Create an SSIS package (<a href="http://learnbycoding.com/2011/07/creating-a-simple-ssis-package-using-bids/" rel="nofollow noreferrer">Steps to create an SSIS package</a>). This example uses BIDS 2005. I have named the package in the format YYYYMMDD_hhmm in the beginning followed by SO stands for Stack Overflow, followed by the SO question id, and finally a description. I am not saying that you should name your package like this. This is for me to easily refer this back later. Note that I also have a Data Sources named Adventure Works. I will be using Adventure Works data source, which points to AdventureWorks database downloaded from <a href="http://msftdbprodsamples.codeplex.com/" rel="nofollow noreferrer">this link</a>. The example uses SQL Server 2008 R2 database. Refer screenshot <strong>#1</strong>.</p>\n\n<p>In the AdventureWorks database, create a stored procedure named <em>dbo.GetCurrency</em> using the below given script.</p>\n\n<pre><code>CREATE PROCEDURE [dbo].[GetCurrency]\nAS\nBEGIN\n    SET NOCOUNT ON;\n    SELECT \n    TOP 10      CurrencyCode\n            ,   Name\n            ,   ModifiedDate \n    FROM        Sales.Currency\n    ORDER BY    CurrencyCode\nEND\nGO\n</code></pre>\n\n<p>On the package’s Connection Manager section, right-click and select <em>New Connection From Data Source</em>. On the <em>Select Data Source</em> dialog, select <em>Adventure Works</em> and click OK. You should now see the Adventure Works data source under the <em>Connection Managers</em> section.</p>\n\n<p>On the package’s Connection Managers section, right-click again but this time select <em>New Connection…</em>. This is to create the Excel connection. On the Add SSIS Connection Manager, select <em>EXCEL</em>. On the Excel Connection Manager, enter the path <em>C:\\Temp\\Template.xls</em>. When we deploy it to the server, we will change this path. I have selected Excel version <em>Microsoft Excel 97-2005</em> and chose to leave the checkbox <em>First row has column names</em> checked so that the create the Excel file is created column headers. Click <em>OK</em>. Rename the Excel connection to <em>Excel</em>, just to keep it simple. Refer screenshots <strong>#2</strong> - <strong>#7</strong>.</p>\n\n<p>On the package, create the following variable. Refer screenshot <strong>#8</strong>.</p>\n\n<ul>\n<li><em>SQLGetData</em>: This variable is of type String. This will contain the Stored Procedure execution  statement. This example uses the value <em>EXEC dbo.GetCurrency</em></li>\n</ul>\n\n<p>Screenshot <strong>#9</strong> shows the output of the stored procedure execution statement <em>EXEC dbo.GetCurrency</em></p>\n\n<p>On the package’s Control Flow tab, place a <code>Data Flow task</code> and name it as Export to Excel. Refer screenshot <strong>#10</strong>.</p>\n\n<p>Double-click on the Data Flow Task to switch to the Data Flow tab.</p>\n\n<p>On the Data Flow tab, place an <code>OLE DB Source</code> to connect to the SQL Server data to fetch the data from the stored procedure and name it as SQL. Double-click on the OLE DB Source to bring up the OLE DB Source Editor. On the Connection Manager section, select <em>Adventure Works</em> from the OLE DB connection manager, select SQL command from variable from Data access mode and select the variable <em>User::SQLGetData</em> from the Variable name drop down. On the Columns section, make sure the column names are mapped correctly. Click OK to close the OLE DB Source Editor. Refer screenshots <strong>#11</strong> and <strong>#12</strong>.</p>\n\n<p>On the Data Flow tab, place an <code>Excel Destination</code> to insert the data into the Excel file and name it as Excel. Double-click on the Excel Destination to open the Excel Destination Editor. On the Connection Manager section, select Excel from the OLE DB connection manager and select Table or view from Data access mode. At this point, we don’t have an Excel because while creating the Excel connection manager, we simply specified the path but never created the file. Hence, there won’t be any values in the drop down Name of the Excel sheet. So, click the <em>New…</em> button (the second New one) to create a new Excel sheet. On the Create Table window, BIDS automatically provide a create sheet based on the incoming data source. You can change the values according to your preferences. I will simply click OK by retaining the default value. The name of the sheet will be populated in the drop down Name of the Excel sheet. The name of the sheet is taken from the task name, here in this case the Excel Destination, which we have named it as Excel. On the Mappings section, make sure the column names are mapped correctly. Click OK to close the Excel Destination Editor. Refer screenshots <strong>#13</strong> - <strong>#16</strong>.</p>\n\n<p>Once the data flow task is configured, it should look like as shown in screenshot <strong>#17</strong>.</p>\n\n<p>Execute the package by pressing F5. Screenshots <strong>#18</strong> - <strong>#21</strong> show the successful execution of the package in both Control Flow and Data Flow Task. Also, the file is generated in the path <em>C:\\Temp\\Template.xls</em> provided in the Excel connection and the data shown in the stored procedure execution output matches with the data written to the file.</p>\n\n<p>The package developed on my local machine in the folder path <em>C:\\Learn\\Learn.VS2005\\Learn.SSIS</em>. Now, we need to deploy the files on to the Server that hosts the 64-bit version of the SQL Server to schedule a job. So, the folder on the server would be <em>D:\\SSIS\\Practice</em>. Copy the package file (<strong>.dtsx</strong>) from the local machine and paste it in the server folder. Also, in order for the package to run correctly, we need to have the Excel spreadsheet present on the server. Otherwise, the validation will fail. Usually, I create a Template folder that will contain the empty Excel spreadsheet file that matches the output. Later, during run time I will change the Excel output path to a different location using package configuration. For this example, I am going to keep it simple. So, let’s copy the Excel file generated in the local machine in the path <em>C:\\Temp\\Template.xls</em> to the server location <em>D:\\SSIS\\Practice</em>. I want the SQL job to generate the file in the name Currencies.xls. So, rename the file Template.xls to <em>Currencies.xls</em>. Refer screenshot <strong>#22</strong>.</p>\n\n<p>To show that I am indeed going to run the job on the server in a 64-bit edition of SQL Server, I executed the command SELECT @@version on the SQL Server and screenshot <strong>#23</strong> shows the results.</p>\n\n<p>We will use <em>Execute Package Utility</em> (dtexec.exe) to generate the command line parameters. Log into the server which will run the SSIS package in an SQL job. Double-click on the package file, this will bring the Execute Package Utility. On the General section, select File system from Package source. Click on the Ellipsis and browse to the package path. On the Connection Managers section, select Excel and change the path inside the Excel file from C:\\Temp\\Template.xls to D:\\SSIS\\Practice\\Currencies.xls. The changes made in the Utility will generate a command line accordingly on the Command Line section. On the Command Line section, copy the Command line that contains all the necessary parameters. We are not going to execute the package from here. Click <em>Close</em>. Refer screenshots <strong>#24</strong> - <strong>#26</strong>.</p>\n\n<p>Next, we need to set up a job to run the SSIS package. We cannot choose SQL Server Integration Services Package type because that will run under 64-bit and won’t find the Excel connection provider. So, we have to run it as <code>Operating System (CmdExec)</code> job type. Go to SQL Server Management Studio and connect to the Database Engine. Expand SQL Server Agent and right-click on Jobs node. Select New Job…. On the General section of the Job Properties window, provide the job name as 01_SSIS_Export_To_Excel, Owner will be the user creating the job. I have a Category named SSIS, so I will select that but the default category is <em>[Uncategorized (Local)]</em> and provide a brief description. On the Steps section, click <em>New…</em> button. This will bring Job Step properties. On the General section of the Job Step properties, provide Step name as Export to Excel, Select type <code>Operating system (CmdExec)</code>, leave the default Run as account as SQL Server Agent Service Account and provide the following Command. Click OK. On the New Job window, Click OK. Refer screenshots <strong>#27</strong> - <strong>#31</strong>.</p>\n\n<pre><code>C:\\Program Files (x86)\\Microsoft SQL Server\\90\\DTS\\Binn\\DTExec.exe /FILE \n"D:\\SSIS\\Practice\\20110723_1015_SO_21448_Excel_64_bit_Error.dtsx" \n/CONNECTION Excel;"\\"Provider=Microsoft.Jet.OLEDB.4.0;Data \nSource=D:\\SSIS\\Practice\\Currencies.xls;Extended Properties=""EXCEL 8.0;HDR=YES"";\\""  \n/MAXCONCURRENT " -1 " /CHECKPOINTING OFF  /REPORTING EWCDI\n</code></pre>\n\n<p>The new job should appear under SQL Server Agent –> Jobs node. Right-click on the newly created job 01_SSIS_Export_To_Excel and select <em>Start Job at Step…</em>, this will commence the job execution. The job will fail as expected because that is the context of this issue. Click Close to close the Start Jobs dialog. Refer screenshots <strong>#32</strong> and <strong>#33</strong>.</p>\n\n<p>Let’s take a look at what happened. Go to SQL Server Agent and Jobs node. Right-click on the job 01_SSIS_Export_To_Excel  and select View History. This will bring the Log File Viewer window. You can notice that the job failed. Expand the node near the red cross and click on the line that Step ID value of 1.  At the bottom section, you can see the error message <strong><code>Option “8.0;HDR=YES’;” is not valid.</code></strong> Click Close to close the Log File Viewer window. Refer screenshots <strong>#34</strong> and <strong>#35</strong>.</p>\n\n<p>Now, right-click on the job and select Properties to open the Job Properties. You can also double-click on the job to bring the Job Properties window. Click on the Steps on the left section. and click Edit. Replace the command with the following command and click OK. Click OK on the Job Properties to close the window. Right-click on the job 01_SSIS_Export_To_Excel and select Start Job at Step…, this will commence the job execution. The job will fail execute successfully. Click Close to close the Start Jobs dialog. Let’s take a look at the history. Right-click on the job 01_SSIS_Export_To_Excel  and select View History. This will bring the Log File Viewer window. You can notice that the job succeeded during the second run. Expand the node near the green tick cross and click on the line that Step ID value of 1.  At the bottom section, you can see the message Option The step succeeded. Click Close to close the Log File Viewer window. The file D:\\SSIS\\Practice\\Currencies.xls will be successfully populated with the data. If you execute the job successfully multiple times, the data will get appended to the file and you will find more data. As I mentioned earlier, this is not the right-way to generate the files. This example was created to demonstrate a fix for this issue. Refer screenshots <strong>#36</strong> - <strong>#38</strong>.</p>\n\n<p>Screenshot <strong>#39</strong> shows the differences between the working and the non-working command line arguments. The one on the right is the working command line and the left one is incorrect. It required another double quotes with backslash escape sequence to fix the error. There could be other ways to fix this well but this option seems to work.</p>\n\n<p>Thus, the example demonstrated a way to fix the command line argument issue while accessing Excel data source from an SSIS package that is deployed on a 64-bit server.</p>\n\n<p>Hope that helps someone.</p>\n\n<p><strong>Screenshots:</strong></p>\n\n<p><strong>#1:</strong> Solution_Explorer</p>\n\n<p><img src="https://i.stack.imgur.com/8LXYw.png" alt="Solution_Explorer"></p>\n\n<p><strong>#2:</strong> New_Connection_Data_Source</p>\n\n<p><img src="https://i.stack.imgur.com/kLUaJ.png" alt="New_Connection_Data_Source"></p>\n\n<p><strong>#3:</strong> Select_Data_Source</p>\n\n<p><img src="https://i.stack.imgur.com/dctco.png" alt="Select_Data_Source"></p>\n\n<p><strong>#4:</strong> New_Connection</p>\n\n<p><img src="https://i.stack.imgur.com/ENgBq.png" alt="New_Connection"></p>\n\n<p><strong>#5:</strong> Add_SSIS_Connection_Manager</p>\n\n<p><img src="https://i.stack.imgur.com/e477v.png" alt="Add_SSIS_Connection_Manager"></p>\n\n<p><strong>#6:</strong> Excel_Connection_Manager</p>\n\n<p><img src="https://i.stack.imgur.com/rLuSb.png" alt="Excel_Connection_Manager"></p>\n\n<p><strong>#7:</strong> Connection_Managers</p>\n\n<p><img src="https://i.stack.imgur.com/Tw4K1.png" alt="Connection_Managers"></p>\n\n<p><strong>#8:</strong> Variables</p>\n\n<p><img src="https://i.stack.imgur.com/wOuU5.png" alt="Variables"></p>\n\n<p><strong>#9:</strong> Stored_Procedure_Output</p>\n\n<p><img src="https://i.stack.imgur.com/mynyS.png" alt="Stored_Procedure_Output"></p>\n\n<p><strong>#10:</strong> Control_Flow</p>\n\n<p><img src="https://i.stack.imgur.com/DTucs.png" alt="enter image description here"></p>\n\n<p><strong>#11:</strong> OLE_DB_Source_Connections_Manager</p>\n\n<p><img src="https://i.stack.imgur.com/tLHQP.png" alt="OLE_DB_Source_Connections_Manager"></p>\n\n<p><strong>#12:</strong> OLE_DB_Source_Columns</p>\n\n<p><img src="https://i.stack.imgur.com/uxZZ4.png" alt="OLE_DB_Source_Columns"></p>\n\n<p><strong>#13:</strong> Excel_Destination_Editor_New</p>\n\n<p><img src="https://i.stack.imgur.com/nyUgx.png" alt="Excel_Destination_Editor_New"></p>\n\n<p><strong>#14:</strong> Excel_Destination_Create_Table</p>\n\n<p><img src="https://i.stack.imgur.com/UN5xT.png" alt="Excel_Destination_Create_Table"></p>\n\n<p><strong>#15:</strong> Excel_Destination_Edito</p>\n\n<p><img src="https://i.stack.imgur.com/RdH54.png" alt="Excel_Destination_Edito"></p>\n\n<p><strong>#16:</strong> Excel_Destination_Mappings</p>\n\n<p><img src="https://i.stack.imgur.com/iPO8y.png" alt="Excel_Destination_Mappings"></p>\n\n<p><strong>#17:</strong> Data_Flow</p>\n\n<p><img src="https://i.stack.imgur.com/wLxa4.png" alt="Data_Flow"></p>\n\n<p><strong>#18:</strong> Successful_Package_Execution_Control</p>\n\n<p><img src="https://i.stack.imgur.com/TZ0ou.png" alt="Successful_Package_Execution_Control"></p>\n\n<p><strong>#19:</strong> Successful_Package_Execution_Data_Flow</p>\n\n<p><img src="https://i.stack.imgur.com/FI6VA.png" alt="Successful_Package_Execution_Data_Flow"></p>\n\n<p><strong>#20:</strong> C_Temp_File_Created</p>\n\n<p><img src="https://i.stack.imgur.com/VMjnn.png" alt="C_Temp_File_Created"></p>\n\n<p><strong>#21:</strong> Data_Populated</p>\n\n<p><img src="https://i.stack.imgur.com/IYhUg.png" alt="Data_Populated"></p>\n\n<p><strong>#22:</strong> File_On_Server</p>\n\n<p><img src="https://i.stack.imgur.com/k7hKu.png" alt="File_On_Server"></p>\n\n<p><strong>#23:</strong> SQL_Server_Version</p>\n\n<p><img src="https://i.stack.imgur.com/n2gpY.png" alt="SQL_Server_Version"></p>\n\n<p><strong>#24:</strong> Execute_Package_Utility_General</p>\n\n<p><img src="https://i.stack.imgur.com/ZNCW0.png" alt="Execute_Package_Utility_General"></p>\n\n<p><strong>#25:</strong> Execute_Package_Utility_Connection_Managers</p>\n\n<p><img src="https://i.stack.imgur.com/o39ar.png" alt="Execute_Package_Utility_Connection_Managers"></p>\n\n<p><strong>#26:</strong> Execute_Package_Utility_Command_Line</p>\n\n<p><img src="https://i.stack.imgur.com/mq9Ts.png" alt="Execute_Package_Utility_Command_Line"></p>\n\n<p><strong>#27:</strong> Job_New_Job</p>\n\n<p><img src="https://i.stack.imgur.com/Dx17J.png" alt="Job_New_Job"></p>\n\n<p><strong>#28:</strong> New_Job_General</p>\n\n<p><img src="https://i.stack.imgur.com/Wwk7H.png" alt="New_Job_General"></p>\n\n<p><strong>#29:</strong> New_Job_Step</p>\n\n<p><img src="https://i.stack.imgur.com/5VDWF.png" alt="New_Job_Step"></p>\n\n<p><strong>#30:</strong> New_Job_Step_General </p>\n\n<p><img src="https://i.stack.imgur.com/MTXMT.png" alt="New_Job_Step_General"></p>\n\n<p><strong>#31:</strong> New_Job_Steps_Added</p>\n\n<p><img src="https://i.stack.imgur.com/p9IeS.png" alt="New_Job_Steps_Added"></p>\n\n<p><strong>#32:</strong> Job_Start_Job_at_Step</p>\n\n<p><img src="https://i.stack.imgur.com/Qpef2.png" alt="Job_Start_Job_at_Step"></p>\n\n<p><strong>#33:</strong> SQL_Job_Execution_Failure</p>\n\n<p><img src="https://i.stack.imgur.com/qSPdR.png" alt="SQL_Job_Execution_Failure"></p>\n\n<p><strong>#34:</strong> View_History</p>\n\n<p><img src="https://i.stack.imgur.com/xZqWk.png" alt="View_History"></p>\n\n<p><strong>#35:</strong> SQL_Job_Error_Message</p>\n\n<p><img src="https://i.stack.imgur.com/oYovo.png" alt="SQL_Job_Error_Message"></p>\n\n<p><strong>#36:</strong> SQL_Job_Execution_Success</p>\n\n<p><img src="https://i.stack.imgur.com/fYeKc.png" alt="SQL_Job_Execution_Success"></p>\n\n<p><strong>#37:</strong> SQL_Job_Success_Message</p>\n\n<p><img src="https://i.stack.imgur.com/3yEQe.png" alt="SQL_Job_Success_Message"></p>\n\n<p><strong>#38:</strong> Excel_File_Generated</p>\n\n<p><img src="https://i.stack.imgur.com/ovlVm.png" alt="Excel_File_Generated"></p>\n\n<p><strong>#39:</strong> Command_Comparison</p>\n\n<p><img src="https://i.stack.imgur.com/2h7mX.png" alt="39_Command_Comparison"></p>\n'}]
['https://Stackoverflow.com/questions/21448', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2375/']