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 |
|
kashif.special2005
Starting Member
10 Posts |
Posted - 2012-04-20 : 01:24:45
|
| Hi,I don't know how to export excel data into sql server 2000, I find below code from new but it is giving me an error message that "Incorrect Syntax near 'Excel', I don't know why please help.Sub ADOXLtoSQLSRV()Dim cn As ADODB.ConnectionDim strConn As StringDim strSQL As StringDim strXLSource As StringDim lngRecsAff As LongstrConn = strConn & "Provider=SQLOLEDB;Data Source=;"strConn = strConn & "Initial Catolog=AdventureWorks;Trusted_Connection=YES"Set cn = New ADODB.Connectioncn.Open strConnstrXLSource = "C:\Users\Kashif\Desktop\Book1.xls;Extended Properties=Excel 8.0"''Import by using OPENDATASOURCE.''INSERT INTO'(SQL Fields)''SELECT''FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0', 'Data Source=$]strSQL = " INSERT INTO dbo.kashif1 "strSQL = strSQL & " ([name,Salary]) "strSQL = strSQL & " SELECT [Name,Salary] "strSQL = strSQL & " FROM "strSQL = strSQL & " OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',Excel 8.0, 'Data Source=" & strXLSource & "')[Sheet1$] "Debug.Print strSQLcn.Execute strSQL, lngRecsAff, adExecuteNoRecordsDebug.Print "Records affected: " & lngRecsAffcn.CloseSet cn = NothingEnd SubPlease help.Thanks & Regards,Kashif. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-20 : 14:54:02
|
| why cant you use export import wizard for this?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|