Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSIS Question Help


SSIS Question Help

Author
Message
rocky_498
rocky_498
SSC Veteran
SSC Veteran (295 reputation)SSC Veteran (295 reputation)SSC Veteran (295 reputation)SSC Veteran (295 reputation)SSC Veteran (295 reputation)SSC Veteran (295 reputation)SSC Veteran (295 reputation)SSC Veteran (295 reputation)

Group: General Forum Members
Points: 295 Visits: 1291
Hi Guys, I have question.

I am creating a SSIS Package, Its runs fine with no problem, Its kinda simple package, Let me explain...

Pulling the data from SQL Table and my destination is flat file (First flat file).
Here i want one more logic
I want to create one more flat file with below information
1) Count from First flat file
2) Flat file name (Naming convention change "Flatfilename_getdate()" from first flat file
3) Time when Package run..

Is anyone can help me
Yelena Varshal
Yelena Varshal
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3480 Visits: 593
Hi,

You can use package variables.

Use @@Rowcount to get the number of rows returned by the query
http://technet.microsoft.com/en-us/library/ms187316.aspx
Assign this @@Rowcount value to a package variable

Generate the file name with GetDate() and assign it to both a package variable and to the file name

You don't need the time the package run as it is in the file name. Or get the time with GetDate() then assign it to both the file name and a package variable.

Then create a second file and write all 3 variables to it.

Yelena


Regards,
Yelena Varshal

Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16380 Visits: 13199
Yelena Varshal (8/22/2013)


You can use package variables.

Use @@Rowcount to get the number of rows returned by the query
http://technet.microsoft.com/en-us/library/ms187316.aspx
Assign this @@Rowcount value to a package variable


Very, very curious how you would do this in an OLE DB Source component.
The way to go is to use the Rowcount component. It is there for a reason.

Yelena Varshal (8/22/2013)

Generate the file name with GetDate() and assign it to both a package variable and to the file name


More info on this:
Dynamic Flat File Connections in SQL Server Integration Services



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
Yelena Varshal
Yelena Varshal
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3480 Visits: 593
Hi,

I can for example use Execute SQL task that queries a Stored Procedure or function that returns @@Rowcount and assign the result to a package variable as decribed in

http://dataqueen.unlimitedviz.com/2012/08/how-to-set-and-use-variables-in-ssis-execute-sql-task/
How To Set and Use Variables in SSIS Execute SQL Task

Yes, you can use the component too


Regards,
Yelena Varshal

Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16380 Visits: 13199
Yelena Varshal (8/22/2013)
Hi,

I can for example use Execute SQL task that queries a Stored Procedure or function that returns @@Rowcount and assign the result to a package variable as decribed in

http://dataqueen.unlimitedviz.com/2012/08/how-to-set-and-use-variables-in-ssis-execute-sql-task/
How To Set and Use Variables in SSIS Execute SQL Task


How would you get the result of your stored procedure into the flat file?



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
Yelena Varshal
Yelena Varshal
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3480 Visits: 593
The result could be written to a variable per the link in my previous post. Then you can output the variable to a text file with the streamwriter using dts.variables collection

Or you can do it much easier. Creaate your own CLR stored procedure that will write stuff to a file and use it without SSIS as a single SQL Script for both result set output and for the second file.

You can also use bcp out


Regards,
Yelena Varshal

Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16380 Visits: 13199
Yelena Varshal (8/22/2013)
The result could be written to a variable per the link in my previous post. Then you can output the variable to a text file with the streamwriter using dts.variables collection

Or you can do it much easier. Creaate your own CLR stored procedure that will write stuff to a file and use it without SSIS as a single SQL Script for both result set output and for the second file.

You can also use bcp out


That's a whole lot of trouble, while you can just use the OLE DB Source and a Rowcount.



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
Yelena Varshal
Yelena Varshal
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3480 Visits: 593
Well, you were asking How... You did not ask Why this is better.... :-)


Regards,
Yelena Varshal

Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16380 Visits: 13199
Yelena Varshal (8/22/2013)
Well, you were asking How... You did not ask Why this is better.... :-)


True true :-)



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
rocky_498
rocky_498
SSC Veteran
SSC Veteran (295 reputation)SSC Veteran (295 reputation)SSC Veteran (295 reputation)SSC Veteran (295 reputation)SSC Veteran (295 reputation)SSC Veteran (295 reputation)SSC Veteran (295 reputation)SSC Veteran (295 reputation)

Group: General Forum Members
Points: 295 Visits: 1291
Hi Guys,

Thank you all for your help. I used RowCount Tranformation...

One more question, I want to display Count and file name and put in to flat file. I got the Count is anyone can help me how i can get file name that I just rename through "File System Task" to add Date Stamp? I can get file name however date stamp is not matched from file that just renamed in File System Task.

Any help?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search