1

When I execute a sql statement like "Select ...", I can only see "...100%" completed...

I want to log the number of rows affected.

How can we do that?

R.D
  • 4,781
  • 11
  • 41
  • 58

3 Answers3

1

run your SELECT from within a stored procedure, where you can log the rowcount into a table, or do anything else to record it...

CREATE PROCEDURE SSIS_TaskA
AS

DECLARE @Rows  int

SELECT ... --your select goes here


SELECT @Rows=@@ROWCOUNT

INSERT INTO YourLogTable
        (RunDate,Message)
    VALUES
        (GETDATE(),'Selected '+CONVERT(varchar(10),ISNULL(@Rows,0))+' rows in SSIS_TaskA')

GO
KM.
  • 101,727
  • 34
  • 178
  • 212
  • isn't there a less Hackish way – R.D Aug 28 '09 at 21:27
  • 2
    I think having SSIS run a query that is _not within_ a stored procedure is a hack. Having SSIS run a procedure allows you to group commands together, which is what you are aking to do. – KM. Aug 31 '09 at 12:22
0

When you use a SQL Task for a select most of the time you give as destination a DataSet Object, you can count the number of ligne from the DataSet

Polo
  • 1,770
  • 4
  • 18
  • 29
0

I believe you could leverage a t-sql output clause on your update or insert statement and capture that as an ssis variable....or just drop it into a sql table.

here is an example...its crappy, but it is an example

UPDATE TOP (10) HumanResources.Employee
SET VacationHours = VacationHours * 1.25 
OUTPUT INSERTED.EmployeeID,
       DELETED.VacationHours,
       INSERTED.VacationHours,
       INSERTED.ModifiedDate
INTO @MyTableVar;

You could output @@ROWCOUNT anyplace you need it to be.

Here is output syntax

http://technet.microsoft.com/en-us/library/ms177564.aspx

Mutix
  • 4,196
  • 1
  • 27
  • 39
KevinV
  • 1