Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count lines of a csv file

Status
Not open for further replies.

Diogo

Technical User
Mar 22, 2001
143
PT
Hello.

I have one file (*.csv) and i would like to count the lines of the file and insert that in one table on the database of the sql server.

Is that possible???

Thanks any way.

DR
 
Do you need to count the lines before it is imported into the database, or will after do?
 
depending on the size of your file it might be just as easy doing an import then select count(*) from yourtable. I haven't heard of dts being used to count from a csv before inserting

simmo
 
you can count the rows using file scripting object

set objfso = server.createobject("Scripting.fileScriptingObject")
set objtstream = objfso.opentextfile("Filelocation",1)

do whiloe not objtstream.atendofstream
intlinenum = objtstream.line
loop

intlinenum will be your total number of rows.

hope this helps.
 
I would like to know if the import was sucessuful, so i'd like to count the lines in the file and compare them after the import.

I have one table to insert the count of records, before and after the import and then i compare.

Thanks any way, and sorry my english...

DR
 
The import should either succeed or fail. This is, either all or none of the data will be imported. If you are running the package from Enterprise Manager, you will receive immediate feedback. If you are running the package from some other source, you can have the status output to a text file and look at the results there.

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top