Avatar of meteorelec
meteorelec
Flag for Ireland asked on

load excel file into temp SQL table

hi all

i have a list of emails that i want to load into a temp SQL table to do some reporting,
i have only one field in excel - 'email'

can anyone advise me on how to do so?
Microsoft SQL Server 2005

Avatar of undefined
Last Comment
catherinelouise

8/22/2022 - Mon
udaya kumar laligondla

http://support.microsoft.com/kb/321686 got the detailed discussion of Excel import
catherinelouise

If you are using SQL Management Studio, you can simply right click on a database, select Tasks, then select Import Data and have the Import Wizard walk you through importing your file - effectively it was create an SSIS package for you.
meteorelec

ASKER
i just want to load the data into a temp table so i can work with it in a query,
eg
DECLARE @TibetanYaks TABLE (
YakID int,
YakName char(30) )

INSERT INTO @TibetanYaks (YakID, YakName)
SELECT YakID, YakName
FROM dbo.Yaks                   -----    -----------------------------------only here i need to point to excel
WHERE YakType = 'Tibetan'
 
 
 i could load it into an actual table, but its not want i want to be doing everytime  
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
catherinelouise

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
meteorelec

ASKER
hi catherine
i am using above to make

DECLARE @emails TABLE (email char(60))
INSERT INTO @emails(email)
SELECT email
FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:\mal\email.xls;Extended Properties=Excel 8.0')...[email$]
 
but i am getting error

OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IDBInitialize::Initialize returned 0x80004005: The provider did not give any information about the error.].
Msg 7399, Level 16, State 1, Line 3
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. The provider did not give any information about the error.
 
catherinelouise

I had the same error when the path to my file was incorrect.  Double check the path, that it is accessible, the filename and the sheet name.
SOLUTION
catherinelouise

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
meteorelec

ASKER
the paths etc are all ok, reading the link to hopefully find something!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
meteorelec

ASKER
issue was i was connected to an sql instance on another server and reading a local file
i ran the query on the actual server and had the file saved locally and it worked 100%
cheers catherinelouise
catherinelouise

I suspected it might be that - right at the end of the thread right? !  Glad you got it worked out.