Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 Development Tools
 Other Development Tools
 inserting excel rows into SQL SERVER 2005
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

57 Posts

Posted - 04/04/2012 :  23:07:06  Show Profile  Reply with Quote
I am working on excel spreadsheet upload process where users export their data via macro VBA into SQL SERVER 2005.

So far I am able to import data from the SQL server into an execl but I am being challenged with writing excel data into SQL SERVER database:

Here is what I am working on
Sub Connect2SQLXpress()

Dim oCon As ADODB.Connection
Dim oRS As ADODB.Recordset

Set oCon = New ADODB.Connection
oCon.ConnectionString = "Driver={SQL Native Client};Server=myserver;Database=DB; Trusted_Connection=yes;"

Set oRS = New ADODB.Recordset
oRS.ActiveConnection = oCon
oRS.Source = "insert into table (ID,Name,State,Code) VALUES (Columns("A":"B":"C":"D"))"




If Not oRS Is Nothing Then Set oRS = Nothing
If Not oCon Is Nothing Then Set oCon = Nothing
MsgBox "All done!"

End Sub

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 04/04/2012 :  23:21:29  Show Profile  Reply with Quote
why not use OPENROWSET or export import wizard for this?

SQL Server MVP

Go to Top of Page

Premature Yak Congratulator

22864 Posts

Posted - 04/17/2012 :  03:51:08  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote


Failing to plan is Planning to fail
Go to Top of Page

Starting Member

2 Posts

Posted - 10/11/2012 :  00:53:15  Show Profile  Reply with Quote
I've learn some excellent stuff here.
Go to Top of Page

Flowing Fount of Yak Knowledge

United Kingdom
2179 Posts

Posted - 10/11/2012 :  01:52:43  Show Profile  Visit jackv's Homepage  Reply with Quote
1) Powershell is very useful in these circumstances
2) Another more manual way is , generate the INSERT staments and run as a script :

Jack Vamvas
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000