473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Export Excel to SQL 2005 table

Scenario :
SQL table has 2 columns SQ1, SQ2
Excel sheet has three columns : EX1, EX2, EX3

SQ1 matches with EX2
SQ2 matches with EX3

I would like to insert the rows where EX1='X'. EX1 is the left most column in th Excel sheet.

Here's what I am trying. Could you suggest any changes/suggestions?

-- Link server logic
IF EXISTS (SELECT srv.name FROM sys.servers srv WHERE srv.server_id != 0 AND srv.name = N'Config_spreadsheet_load')EXEC master.dbo.sp_dropserver @server=N'Config_spreadsheet_load', @droplogins='droplogins'
GO

--This is the link logic to connect the spreadsheet to the database
sys.sp_addlinkedserver 'Config_spreadsheet_load',
Excel',
'Microsoft.Jet.OLEDB.4.0',
In : @ExcelfileName,
'excel 8.0;
IMEX=1;
GO

-- Insert Plan Codes, for the column (PLC_NEW_COL) marked as ‘X’
insert into Plan_code (SQ1,
SQ2)
-- **** How can I have the logic for checking EX1='X'
where PLC_NEW_COL like ‘X’
-- Once the data has been created, clean-up
Apr 23 '08 #1
2 1644
ck9663
2,878 Expert 2GB
try OPENROWSET

-- CK
Apr 24 '08 #2
madankarmukta
308 256MB
Hi,
In stead of having such a complex query to fetch the xcel..i will suggest you to import the excel sheets data into the Temporary Table using import export vizard in sql server 2005 n then write a executable query to have a maych with your existing data or also can insert it to the destination table if it does not exist.

Thanks.
Apr 25 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table....
7
by: Keon | last post by:
Hoi, I'm using a database with alot of records in 1 table (more than 3000). If i want to export this table to excel i only get it till record 2385. Do someone know how i can solve this...
5
by: Maria L. | last post by:
Hi, I need to export the content of a DataGrid (in Windows application in C#), into an Excel spreadsheet. Anyone knows how to do this? Any code snippets would help! thanks a lot, Maria
4
by: Hans [DiaGraphIT] | last post by:
Hi! I want to export a dataset to an excel file. I found following code on the net... ( http://www.codeproject.com/csharp/Export.asp ) Excel.ApplicationClass excel = new ApplicationClass();...
4
by: Prasad Dannani | last post by:
Hi, We have to export our data in sql server table to any excel sheet. We have a template to export, using oledb we are inserting rows to this template and generating the excel output. The...
3
by: nologin | last post by:
Is it possible to export data exposed by DataView to Excel file for example ? Seba
4
by: paul.chae | last post by:
I have a table in Access with about 3000 records. There are ~60 unique values in the ID field for the 3000 records. What I would like to do is automatically generate multiple Excel worksheets...
13
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.