Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / February 2005



Tip: Looking for answers? Try searching our database.

OpenDataSource

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex - 28 Feb 2005 11:40 GMT
Hi,

Could anybody supply me with the correct SQL statement to load a .csv file
into a SQL Server 2000 table.  I am hoping to run this statement from a VB6
application, thanks.

Alex
William (Bill) Vaughn - 28 Feb 2005 18:15 GMT
Use DTS.

Signature

____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

> Hi,
>
[quoted text clipped - 4 lines]
>
> Alex
Val Mazur - 28 Feb 2005 23:54 GMT
Hi Alex,

You could use BULK INSERT statement from the SQL Server to do this or you
could use next kind of code (I did not test it, but it should work)

Dim cn As ADODB.Connection
Dim strSQL As String
Dim lngRecsAff As Long
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\pathtofile\;" & _
       "Extended Properties=""text;HDR=Yes;FMT=Delimited"""

   'Import by using Jet Provider.
   strSQL = "SELECT * INTO [odbc;Driver={SQL Server};" & _
       "Server=<server>;Database=<database>;" & _
       "UID=<user>;PWD=<password>].MySQLTableNameHere " & _
       "FROM [TextFile.csv]"
   Debug.Print strSQL

   cn.Execute strSQL, lngRecsAff, adExecuteNoRecords

   cn.Close
   Set cn = Nothing

Signature

Val Mazur
Microsoft MVP

http://xport.mvps.org

> Hi,
>
[quoted text clipped - 4 lines]
>
> Alex
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.