SQL Server unable to upload excel file - sql

I try to create a new table by uploading an Excel file, but it is stuck on the last step of SQL Server Import and Export Wizard; the openrowset function works

While importing excel file in sql server you would have got excel, Select microsoft Excel 97-2003 format if you are using latest verion of excel Or else it's better you export it to access database and upload it.

Related

Upload text files to MS SQL server automatically

I frequently receive text and excel files which I have to upload in local MS SQL Server. Is there any tool or command available that can automate this task. For Bulk upload provided by MS SQL you have to create the blank table first, I dont want to create a new table manually each time. Please help
Don't need to create a data table manually . In MS Sql server there is a function for that .
Right click on Database Name
Then go to 'Tasks' and then go to the tab 'Import Data' & click on that
you will get the data export , import wizard, Click next.
If excel file , Select data source as 'Microsoft Excel' then browse the excel file (make sure your excel file save in 97-2003 format).
if text file , Select data source as 'Flat File Source' , then browse the file .
Proceed with the wizard , you will get the data table with relevant data.

OpenRowSet returning only one result

I am using OPENROWSET and Microsoft.ACE.OLEDB.12.0 to retrieve data in SSMS from an Excel 2007 (.xlsx) file. When I execute the query I only get the title of the first column (Excel cell A1) and F2, F3, etc. for the rest of the columns and no data within the table. The Excel file contains data; however, OPENROWSET is not retrieving anything other than cell A1.
I have tried both
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=C:\filepath.xlsx','SELECT * FROM [Sheet1$]')
and
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=C:\filepath.xlsx',[Sheet1$])
I get the same result for both queries.
I have also tried using the Import/Export Wizard (64-bit) and when I am on the 'Select Source Tables and Views' and use Edit Mappings... I receive the following error:
Column information for the source and destination data could not be retrieved
-Unexpected error from external database driver(1).
**Additional information**
->Unexpected error from external database driver (1).(Microsoft Access Database Engine)
I have a 64-bit version of SQL Server that is being used. Also, this is an Excel file that I receive from an outside source. The other Excel files I receive from outside sources do not give me any problems when retrieving data using the same method. Additionally, I am using SQL Server 2008 R2 and the Excel file is located on the same drive as the SQL Server.
Any help is greatly appreciated. It would be nice if I could get this working so I can handle moving the data from these files over to a SSIS package.

How can I impoprt data from SAP system to excel using VBA

Can anyone help me out regarding A standard code for importing data from SAP SYSTEM TO EXCEL using VBA. I use SE16 transaction and a table named .I need to import data from TFACS table to excel using vba.
If you have access to SE16n you can export directly from there to csv or text file. You can also get with IT to create a nightly spool that will dump a text file into a folder and then link directly to that file with excel.

BCP utility to create a format file, to import Excel data to SQL Server 2008 for BULK insertion

Am trying to import Excel 2003 data into SQL table for SQL Server 2008.
Tried to add a linked server but have met with little success.
Now am trying to check if there's a way to use the BCP utility to do a BULK insert or BULK operation with OPENROWSET, using a format file to get the Excel mapping.
First of all, how can I create a format file for a table, that has differently named columns than the Excel spreadsheet colums?
Next, how to use this format file to import data from say a file at: C:\Folder1\Excel1.xsl
into table Table1 ?
Thank you.
There's some examples here that demonstrate what the data file should look like (csv) and what the format file should look like. Unless you need to do this lots I'd just hand-craft the format file, save the excel data to csv, then try using bcp or OPENROWSET.
The format file specifies the column names for the destination. The data file doesn't have column headings so you don't need to worry about the excel (source) cols being different.
If you need to do more mapping etc, then create an SSIS package. You can use the data import wizard to get you started, then save as SSIS package, then edit to your heart's content.
If it's a one-off I'd use the SQL data import size, from right-click on database in mgmt studio. If you just have a few rows to import from excel I typically open a query to Edit Top 200 rows, edit the query to match the columns I have in excel, then copy and paste the rows from excel into SQL mgmt studio. Doesn't handle errors very well, but quick.

How can import xlsx file to Sql server 2000

Recently i moved to office 2007. im trying to import excel file to sql server 2000 using import and export data tool ,the tool gave data source as excel 97 - 2000 but while importing xlsx file ,im getting error "Error source Microsoft Jet databse Engine", external table is not in the expected format. Can you tell me how can i import office excel file xlsx to sql server 2000 using import and export data tool.
Appreciate your prompt comments
You could use an OLEDB connection, assuming DTS supports it. It's been a while since I've used it, so I can't remember. Connection looks something like this: Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES";
If your DTS server doesn't have Office installed you'll need to install the drivers:
http://www.microsoft.com/downloads/details.aspx?familyid=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en
The simple way is use Access 2007 to create a Access Project to connect to SQL 2000, and then import Excel 2007 data by Access 2007 Project.
Saving the document into 97-2003 format is fine when you have a spreadsheet that is smaller than 65536 rows, if it's not then using GordonB's link works
I agree with "schooner", the easiest way to import Excel 2007 into SQL 2K is to save the excel document into a 97-2003 format.
You could always just save it to a 97-2000 format XLS file