Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Flat file record count inside script task Expand / Collapse
Author
Message
Posted Friday, June 27, 2008 6:54 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, May 15, 2014 3:17 AM
Points: 53, Visits: 291
Hi All,

I have a requirement where , i need to get number of records present in the flat file . i need to achive this inside a script task . Can anyone help on this?

Thanks
Arun
Post #524936
Posted Monday, June 30, 2008 12:04 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, November 17, 2014 3:55 PM
Points: 320, Visits: 362
Well, I find it weird that the requirement actually includes doing it in a script task because normally requirements don't care how you get it done as long as the end result is met. However... as for counting the rows in that flatfile, you'll have to move them somewhere and for each row send it to a script task where you just increment a local var for each row that passes. It's actually pretty easy.

However, if the script is only going to count the rows, then you're better off going the easy route and putting a rowcount task between the file and its destination.


Watch my free SQL Server Tutorials at:
http://MidnightDBA.ITBookworm.com

Read my book reviews at:
www.ITBookworm.com

Blog Author of:
Database Underground -- http://www.infoworld.com/blogs/sean-mccown
DBA Rant – http://dbarant.blogspot.com
Post #526142
Posted Monday, June 30, 2008 9:38 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, May 15, 2014 3:17 AM
Points: 53, Visits: 291
crever , thanks for the reply.

can u let me know the transformation where row count is possible (other than script task) , and can u also outline how to do it?

i need this rowcount to be stored in a variable/somewhere , since i need to do some processing inside the script task based on this.

Thanks,
Arun
Post #526306
Posted Monday, June 30, 2008 10:07 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, November 17, 2014 3:55 PM
Points: 320, Visits: 362
I have a video on how to use the rowcount.

http://midnightdba.itbookworm.com/SSISRowCount/SSISRowCount.html


Watch my free SQL Server Tutorials at:
http://MidnightDBA.ITBookworm.com

Read my book reviews at:
www.ITBookworm.com

Blog Author of:
Database Underground -- http://www.infoworld.com/blogs/sean-mccown
DBA Rant – http://dbarant.blogspot.com
Post #526307
Posted Tuesday, July 1, 2008 2:35 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, June 25, 2009 11:35 AM
Points: 61, Visits: 112
Add a Flat File Source and Pass the rows to a row count transformation.
This should do the job.


Regards
Venkat
http://sqlblogging.blogspot.com
Post #526406
Posted Wednesday, October 8, 2008 3:58 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, February 19, 2009 10:45 AM
Points: 1, Visits: 14
I am having problems using the count rows task.
What I want to do is use a FOR EACH LOOP to get the name of the files. Then use a SQL Task to put the row counts in a SQL table. The files would be ragged right. The connection object doesn't like having an expression for the connection string.

I have no problem if I hard code one file name and run it.

Could someone help me with this?
Post #582975
Posted Thursday, October 9, 2008 8:50 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, August 26, 2014 9:05 PM
Points: 441, Visits: 933
To get the name of files in a directory, I suggest you review this article:

Accessing the Windows File System from SQL Server
Written By: Edgewood Solutions Engineers -- 6/12/2007

http://www.mssqltips.com/tip.asp?tip=1263

Problem
Within my SQL Server T-SQL stored procedures and scripts I need to find out the files in a specific directory. What are some approaches to do so? I need some flexibility to capture the file names and general information for subsequent processing. What are the native SQL Server options as well as the custom options that are available?


Post #583382
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse