SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


logging output from Execute T-SQL task


logging output from Execute T-SQL task

Author
Message
bobd125
bobd125
SSC-Enthusiastic
SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)

Group: General Forum Members
Points: 181 Visits: 195
I have a Execute T-SQL task which purged records from table. I would like to record in a log file the record count of how many records where deleted. Is this done by turning logging on?
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)

Group: General Forum Members
Points: 51933 Visits: 21170
bobd125 (1/10/2013)
I have a Execute T-SQL task which purged records from table. I would like to record in a log file the record count of how many records where deleted. Is this done by turning logging on?


Your ExecuteSQL task needs to return the count, which you can map to a package variable.

The way in which you do this depends on the exact SQL you have written, but @@rowcount might be your friend.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39964 Visits: 14412
Here is a tutorial on how you might be able to capture the number of affected rows into a variable, depending on how your SQL Statement in your Execute SQL Task is constructed.

http://microsoft-ssis.blogspot.com/2011/03/rowcount-for-execute-sql-statement.html

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)

Group: General Forum Members
Points: 216280 Visits: 41986
bobd125 (1/10/2013)
I have a Execute T-SQL task which purged records from table. I would like to record in a log file the record count of how many records where deleted. Is this done by turning logging on?


Not sure why you're using SSIS for such a simple thing. Just write a stored procedure and have it capture the rowcount(s) in a log table.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39964 Visits: 14412
Jeff Moden (1/13/2013)
bobd125 (1/10/2013)
I have a Execute T-SQL task which purged records from table. I would like to record in a log file the record count of how many records where deleted. Is this done by turning logging on?


Not sure why you're using SSIS for such a simple thing. Just write a stored procedure and have it capture the rowcount(s) in a log table.

That would seem to require a decision to shift where the logging took place since the original question talked about a log file. If you wanted the log data to a table, but later bring the information out to a file so it could be emailed (typical case) then I guess that could be a compromise.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
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