Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
JARON
Starting Member
9 Posts |
Posted - 2010-01-04 : 06:34:27
|
| Hi all,I want to import an excel file and save it to sql table with the same fields.The scenario is like this: Browsing and uploading the file from the system, then when i click the "Import Button", the data in the excel file should be saved in the sql table, i need the code within the "Import Button"Anyone to help?Thanks in advanceRonald |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-05 : 03:27:27
|
| seems like what you need is a sql job which imports data from excel to sql table? will excel format be consistent? |
 |
|
|
behrman
Yak Posting Veteran
76 Posts |
Posted - 2010-01-06 : 12:15:17
|
| Hi there,You've got a few options. Here are the ones I would recommend.Using the SQL Server BCP utility* You have to scroll all the way to bottom for the relevant post.Using ADO.NET to read the data in ExcelI've used the first option with CSV files. I'm not sure if you can control how your spreadsheet will be formatted. But this option is worth trying.I've also used the second option successfully.Both require you to save the file on disk first (which may or may not be desirable for your application). I think the second option would better because it is easier to debug as everything would be in C# code. I once used the first option because I was importing hundreds of thousands of records in one file so it was faster that way.All the best.RAQ Report: Web-based Excel-like Java reporting tool |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|