Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

SQL Server 2000/Excel

I have a list of Customer Numbers in Excel that I am trying to find a match in SQL Server 2000.  I am looking for a way to link SQL to the spreadsheet.  Such as below:
Can this be done with SQL Server 2000?  Any ideas of other methods.  Thanks.

SELECT * INTO XLImport3 FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:\test\xltest.xls;Extended Properties=Excel 8.0')...[Customers$]
0
fjkaykr11
Asked:
fjkaykr11
  • 4
  • 4
3 Solutions
 
lcohanDatabase AnalystCommented:
How to import data from Excel to SQL Server
http://support.microsoft.com/kb/321686

How to use Excel with SQL Server linked servers and distributed queries
http://support.microsoft.com/kb/306397
0
 
fjkaykr11Author Commented:
I think I was not clear in my post. I don't want to import data from SQL to Excel, I want to do it the other way around. I want to query a list of numbers that I have an excel spreadsheet. Can I do this in SQL Server 2000?
0
 
lcohanDatabase AnalystCommented:
"
I don't want to import data from SQL to Excel, I want to do it the other way around.
I want to query a list of numbers that I have an excel spreadsheet.
"


How to import data from Excel to SQL Server
http://support.microsoft.com/kb/321686

then you "query" it into SQL right?


"Can I do this in SQL Server 2000? "

<<
Article ID: 321686 - Last Review: June 28, 2012 - Revision: 7.0

APPLIES TO
•Microsoft Excel 2000 Standard Edition
•Microsoft SQL Server 2000 Standard Edition
•Microsoft SQL Server 2000 64-bit Edition
•Microsoft Excel 2002 Standard Edition
•Microsoft Excel 97 Standard Edition
>>
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
fjkaykr11Author Commented:
In the Link it states and I am quoting from the link:
"The samples in this article import Excel data by using:

    SQL Server Data Transformation Services (DTS)
    Microsoft SQL Server 2005 Integration Services (SSIS)
    SQL Server linked servers"  ??

I appreciate you sending me a link but I am going to need more help then this
0
 
lcohanDatabase AnalystCommented:
That is if you only read between the lines...anyway I'm trying to help here not start a mud throwing competition but the article says:

Description of the Technique
 The samples in this article import Excel data by using: •SQL Server Data Transformation Services (DTS)
•Microsoft SQL Server 2005 Integration Services (SSIS)
SQL Server linked servers
•SQL Server distributed queries

•ActiveX Data Objects (ADO) and the Microsoft OLE DB Provider for SQL Server
•ADO and the Microsoft OLE DB Provider for Jet 4.0

Requirements
 The following list outlines the recommended hardware, software, network infrastructure, and service packs that are required: •Available instance of Microsoft SQL Server 7.0 or Microsoft SQL Server 2000 or Microsoft SQL Server 2005



Anyway, what Excel version file are you trying to impost and where is it placed when you run the statement you posted above? Is it C:\test\ on the SQL server box where you run the code? What OS is on that SQL box?
0
 
lcohanDatabase AnalystCommented:
And here is a method to use it via Linked Server to Excel file via SQL 2000 Management Studio:

http://support.microsoft.com/kb/306397
0
 
fjkaykr11Author Commented:
I don't think I would be doing a Linked Server.  The operating system of the server is Microsoft Server 2003
Version of Excel is 2010 but the spreadsheet is saved as .xls  (not .xlsx)
Yes the Excel file is in C:\test
0
 
Habib PourfardCommented:
Yes, you can write the following query to select data from excel in Sql 2000:
/*
-- Run this commented code only for the first run to create a temp table
CREATE TABLE #Customer
    (
    [ID] [int] IDENTITY(1, 1) NOT NULL ,
    [Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
    )

INSERT INTO #Customer(Name) VALUES ('John Smith')
INSERT INTO #Customer(Name) VALUES ('Bill Gates')
INSERT INTO #Customer(Name) VALUES ('Mark Zuckerberg')
*/

SELECT  *
FROM    #Customer
        INNER JOIN ( SELECT *
                     FROM   OPENROWSET('Microsoft.Jet.OLEDB.4.0',
                                       'Excel 8.0;Database=C:\CustomerIDs.xls',
                                       [Sheet1$])
                   ) Excel ON #Customer.ID = Excel.CustomerID

Open in new window

I have attached an excel file named CustomerIDs.xls
CustomerIDs.xls
0
 
fjkaykr11Author Commented:
Thanks, that is what I need the T-SQL code is best for me.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now