I just tried to add data from Excel file to SQL Server. I can import as a whole new table, but that means I have to assign the indexes again. Is it possible to import into an existing table?
I saw another question similar to this, and I tried what was suggested there, clicking 'write a query to specify the data transfer'
I entered the following query
INSERT INTO Customer (Customer_Id, Customer_Name, Customer_Company, Address, Phone)
SELECT
A.[Column1], A.[Column2], A.[Column3], A.[Column4], A.[Column5]
FROM
OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=D:\Excel.xls;HDR=YES', 'select * from [Sheet1$]') AS A;
I don't really understand the syntax of the second part of it.. and I'm getting a syntax error in the FROM
clause.
Any clues?