I have an SQL Procedure like below:
CREATE PROCEDURE [dbo].[ExampleSP]
@ID int,
@name varchar(30),
@Counter int output
AS
BEGIN
SET NOCOUNT ON;
---- ********************************************************************************************************
if (@name is not null)
BEGIN
update People
set name = @name
where Id = @ID
END
set @Counter = @@ROWCOUNT
END
What I want is here to count how many rows entered the if condition!
In SSIS -> I have a common variable, called RecordCounter = 0 by default.
I have a Data Flow Task in my Control Flow.
In the Data Flow: -> I have a Flat File Source, reading data from a .dat file.
Example data in the file:
ID|NAME
1 Jack
2
3 Mike
Then, I have Derived Column, adding RecordCounter as a column to the data.
RecordCounter <add as new column> @[User::RecordCounter] four-byte signed integer [DT_I4]
Then, I have OLE DB Command, which enables the data goes row by row to my SP. SQL Command for that is:
EXEC [dbo].[ProcessClientRegistryRecord] ?,?,? OUTPUT
And finally, I have a Row Count item, mapping the variable User::RecordCounter
Here is the figure:
When I run this, the RecordCounter is showing the number of total data in my file, instead how many of them went into the IF block in the StoredProcedure. It should return 2 in this situation for example, not 3. Where is my mistake, how should I fix it? Any help would be appreciated!