September 22, 2008 at 1:26 am
Hi,
I have some .dat files like Activities.dat and Employees.dat. I am uploading this data from these dat files to SQL Server 2005 tables using Bulk insert. The field delimiter is "|".
The Activities.dat has 1089 rows. And 1 row is having error and 1088 rows inserted to the table without any error. And the data is fine.
I have one application which displays the The tolal rows in dat file, and inserted rows into the table, and errors rows count like that.
Inserted rows I am taking count(*) from the table after insertion. The error rows I am calculating like (total rows in dat file - inserted rows).
To count the rows in dat file, I am using dos command and which is executed using cmdshell in sql server.
The dos command is - Find /v /c /i "d:\data\Activities.dat".
For Employees.dat this is giving correct count. But for Activities.dat it is showing 1085. 4 rows less.
Is there any other easy way to count no. of Lines in dat file using SQL or DOS?
Can anyone help me on this?
Thanks,
Peer Md.
September 22, 2008 at 5:40 am
i m not sure but that file may contain commented line(those 4 line)...this ia a blind guess...it might help you 😉
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
September 23, 2008 at 7:57 am
Thnx Bhuvnesh,
It really worked. 🙂
September 23, 2008 at 8:40 am
Can you note what worked? Did the line count work?
You could just import the file into one large table, single column, and then count the rows.
September 23, 2008 at 8:47 am
No.
I have done in different way.
I am inserting to large table only. But if rows have error will not be insereted. I need count inclusive of those rows.
So we need to use some dos or unix scripting.
Thanks,
Peer Md.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply