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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 combining two tables

Author  Topic 

kifeda
Posting Yak Master

136 Posts

Posted - 2009-02-17 : 18:25:49
Hello All,

I'm working in asp and I have two different connections strings, one to an excel file and one to a ms sql server database. what I want to do is copy the data from the excel file to the ms sql server. In order to do so I have to upload the excel file and then read the data from it. I've got that part figured out, but how would I copy data from the excel file to the ms sql server database? Any ideas would be greatly appreciated.

already constructed the sql statement. it looks like this:

INSERT INTO tblleadmanagement
(strfirstName, strlastname, straddress1, strcity, strstate, intzipCode, strphone1, strworkPhone, strhouseType, intCurrentValue, intloanAmount, intfirstBalance, intrate, strfixAjustable, strbehind, strcredt, stryearlyIncome, strbestTimetoCall, strloanDesired, str1stmortageLender, int1stmortgagePayment, intmonthsBehind, strnoticeOfDefault, dtforeclosureDate, stremailAddress, dtdate, strcomments)
SELECT
Name, [Last Name], Address, City, St, Zip, [Home Phone], [Work Phone], [House Type], [Current Value], [Loan Amount], [1st Balance], Rate, [Fix/Adj], Behind, Credit, [Yearly Inc], [Best Time to Call], [Loan Desired], [1st Mortgage Lender], [1st Mortgage Payment], [Months Behind], [Notice of Default], [Foreclosure Date], [Email Address], [Date], Comments
FROM exceltable

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-17 : 18:28:27
You can use OPENROWSET to get data from Excel table.

This topic has been read over 236,000 times.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -