Friday, 15 August 2014

Exporting data to excel from sql server is not working -


I am using the code below to export the data to Excel. This is working fine when the Excel file is empty but when I update to clear the file, the inserted query is executed successfully, but Excel is showing blank.

  update openrowset ('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0; Database = E: \ .. \ .xlsx;', 'Column 1, Column 2, Column 3 [Sheet 1 $] ') Set Column 1 = Faucet, Column 2 = Zero, Column 3 = Moisten OpenOrgeST (' Microsoft. ACE OLEDB.0.1.0 '' Excel 12.0; Database = E: \. \ .xlsx; ' , Select from 'SELECT * FROM [Sheet1 $]') Table 1, Column 2, Column 3 Table_name  

I

I have read online, then OpenRoseet is read-only so that instead you have OP ENDATESOURCE is required to use. Try something like this.

  Update OPENDATASOURCE ('Microsoft.ACE.OLEDB.12.0', 'Data Source = E: \ ... \ YourExcelFile.xlsx ;; Extended Properties = Excel 12.0') ... [ Sheet1 $] Set Column 1 = Faucet, Column 2 = Zero, Column 3 = Openedset ('Microsoft. ACE OLEDB .12.0', 'Data Source = E: \ ... \ YourExcelFile.xlsx; Extended Properties = Excel 12.0 ') ... [Sheet 1 $] select column 1, column 2, column 3, table_name  

No comments:

Post a Comment