troubleshooting Question

Importing Excel File into SQL Server fails

Avatar of skull52
skull52Flag for United States of America asked on
Microsoft SQL ServerMicrosoft SQL Server 2008
14 Comments1 Solution3624 ViewsLast Modified:
I am trying to import an excel file into SQL Server 2008R2, the excel file is on the server I am importing from I have checked the file and it looks fine but I am getting the following error;  
Msg 7357, Level 16, State 2, Line 1
Cannot process the object "SELECT * FROM [CODE$]". The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" indicates that either the object has no columns or the current user does not have permissions on that object.
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[NOSALE1YR]') AND type in (N'U'))
DROP TABLE [dbo].[NOSALE1YR]
GO
SELECT * --INTO NOSALE1YR
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
    'Excel 12.0 Xml;HDR=YES;Database=\\AMCHAR_GP1\NotSold\NOSALE1YR.xlsx',
    'SELECT * FROM [CODE$]');
 
INSERT INTO SSGPR100
(SSGPROMO, ITEMNMBR, CUSTNMBR, STRTDATE, ENDDATE, SSG_Customer_Price, MRKDNAMT, PRICELVL, UOFM)
SELECT	 n.SSGPROMO, 
		 n.ITEMNMBR,
		 n.CUSTNMBR,
		 n.STRTDATE, 
		 n.ENDDATE, 
		 n.SSG_Customer_Price, 
		 n.MRKDNAMT, 
		 n.PRICELVL, 
		 n.UOFM
FROM NOSALE1YR n 
left join SSGPR100 s ON n.SSGPROMO = s.SSGPROMO
WHERE s.SSGPROMO IS NULL
ASKER CERTIFIED SOLUTION
Mark Wills
Topic Advisor
Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros