Counting Records | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Counting Records

I have a DTS Job that creates a TXT File. I will then email the file along with a message of how many records are in the file. I know of a way selecting the records and inserting them into a txt file and then selecting the same records and inserting them into a table. Once in the table a simple query is used to count the records. My files are very large and I want to avoid the double step of selecting all the files twice. Is there a way to either count the records in the created txt file or better yet, store the initial count of processed records? Thank You,
You can take help of global variables in this case, may refer to fyi. Satya SKJ
Microsoft SQL Server MVP
Contributing Editor & Forums Moderator
This posting is provided AS IS with no rights for the sake of knowledge sharing.
You can use global variable method which Satya mentioned… There is another alternate method using sql permnant table… 1. Create a table with filename, count, date etc… column… 2. Once you insert data into your output table… write the rowcount,file name to which you are extracting and date of extraction etc. to new table and
3. query the newly created table before sending email using xp-sendmail… This way you will have the history how much data you sent…even you check the file size write to the table…
Mohammed U.