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

logging output from Execute T-SQL task Expand / Collapse
Author
Message
Posted Thursday, January 10, 2013 1:30 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, March 21, 2014 2:32 PM
Points: 25, Visits: 178
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?
Post #1405629
Posted Thursday, January 10, 2013 1:44 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:06 PM
Points: 5,047, Visits: 11,797
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.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1405634
Posted Sunday, January 13, 2013 9:19 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Saturday, August 23, 2014 8:34 AM
Points: 7,097, Visits: 12,601
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
Post #1406472
Posted Sunday, January 13, 2013 9:45 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 4:03 PM
Points: 36,983, Visits: 31,508
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1406565
Posted Monday, January 14, 2013 6:59 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Saturday, August 23, 2014 8:34 AM
Points: 7,097, Visits: 12,601
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
Post #1406698
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse