I am importing data from binary data files into SQL Server. This is the code I am using:
Do While Not EOF(1)
Get #1, , NonStdCurrRecord
adoRS.AddNew
adoRS!Field1 = CDate(NonStdCurrRecord.Field1)
adoRS!Field2 = CSng(NonStdCurrRecord.Field2)
adoRS!Field3 = CSng(NonStdCurrRecord.Field3)
adoRS!Field4 = CSng(NonStdCurrRecord.Field4)
adoRS!Field5 = CSng(NonStdCurrRecord.Field5)
adoRS!Field6 = CSng(NonStdCurrRecord.Field6)
adoRS!Field7 = CSng(NonStdCurrRecord.Field7)
adoRS.Update
Loop
Unfortunately, it takes about 8 mins to import a file with 180k records. Is there a faster way to do this?
maybe bcp?
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/sqlcmpt9/html/c0af54f5-ca4a-4995-a3a4-0ce39c30ec38.htm
The bcp utility bulk copies data between an instance of Microsoft SQL Server 2005 and a data file in a user-specified format. The bcp utility can be used to import large numbers of new rows into SQL Server tables or to export data out of tables into data files.
Hope, it helps.
|||Thank you for the tip but I don't like requiring users to fiddle with command line utilities. This really has to be done programatically.|||ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/dataacc9/html/00d0311f-8b71-4ad6-824d-0e89119347a3.htm
maybe this link would be helpful?
Thanks
No comments:
Post a Comment