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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 export excel data into SQL Server table

Author  Topic 

Patyk
Yak Posting Veteran

74 Posts

Posted - 2014-02-24 : 13:43:42
I have an excel worksheet "Output" in my excel spreadsheet. d:\data\ExtractData.xlsm

Output worksheet has the following 3 column data table
Product Type Price
0175301574 t2
0175301574 t3
0175301574 us
0175301574 ud
0175301574 bu
0175301574 r 28.8
0170900874 cd
0170900874 k6
0170900874 k5
0170900874 k4
0170900874 k3
0170900874 c
0170900874 k2
0170900874 k1
0170900874 t1
0170900874 t2
0170900874 t3
0170900874 us 8
0170900874 ud 4.8
0170900874 bu 4.4
0170900874 r 4.8
0170900874 b 4.8
0170900874 p 4.8
0175301384 cd 123.24
0175301384 k6 123.24
0175301384 k5 132.72
0175301384 k4 143.78
0175301384 k3 164.32
0175301384 c 104.28
0175301384 k2 160.21
0175301384 k1 164.32
0175301384 t1 166.37
0175301384 t2 184.86

I need to write a store procedure to import this data, excluding the records without Price into my identical table in SQL Server. Product are Type are the primary keys.

Any Help would be appreciated.

thanks

Mar
Starting Member

47 Posts

Posted - 2014-02-25 : 08:27:40
I would recommend writing a macro to loop through the workbook then pass each row to the stored procedure. Unless you are bound to a SP then bulk insert may be an option.
Go to Top of Page
   

- Advertisement -