How to Use Row Count Transformation

Environment: SQL Server 2008 R2
Purpose: Track number of records, which were loaded into each destination, entity tables or affected by data transaction. Record each table name and the number of records for each  table. 
Code:
CREATE TABLE dbo.PkgAudit
PkgAuditID INT IDENTITY(1, 1),
PackageName VARCHAR(100),
LoadTime DATETIME DEFAULT Getdate(),
Status1 Varchar(50),
Status2 varchar(20),
Status3 Varchar(20)
ETL process: See the following pictures. I have two DFT. Reference to the code in details.
Click here
The first one as below
The second DFT
Logic: Load the data from the staging table/ If matched with SSN then status is record exists in the pkgAudit table. If not matched, records the number of records and the status is inserted table in the DFT#1 (Step#1)
In DFT#2, record the name of the tables and number of records for each table
Expected Results:
1, Pakage, 20140304 10:24:12:17, 4 loaded, 3 inserted in individual and SSN table, 1  exists in SSN
Problem: In DFT #1, I placed RowCount Transformation. It generated a couple errors. I also dont know how to concatenate the name of the table and the number of records and the status of the affected table (inserted or exists or loaded).
I am here to learn as my level of competency is novice. I appreciate the support to ease my learning process. Screen shots is highly appreciated. 
~ I tried to load more than picture but the editor allows only 2 pic per post. hope MSDN peeps improve it

Hi Sandra,
Thank you for your reply.
The expression is used for a variable, then the variable can be used in your INSERT statement. According to your screenshot, the PkgAudit table has five columns that you need to insert into. Please refer to the following steps:
1. Create three Int32 type Package scope variables @TotalCount, @InsertCount, and @MatchCount, and specify their initial value to 4, 3, 1 respectively.
2. Create three String type variables @NumberofRecords, @Status1, and @Status2. Then, set the ValidateAsExpression property of each variable to True, and set the expression for the three variables as follows:
NumberofRecords:  (DT_STR,10,1252)@[User::TotalCount] + " loaded"
Status1:  (DT_STR,10,1252) @[User::InsertCount] + " inserted in individual and SSN table"
Status2:  (DT_STR,10,1252) @[User::MatchCount] + " in SSN"
Please refer to the following screenshot:
3. In the Execute SQL Task, modify your SQLStatement to:
INSERT INTO dbo.PkgAudit(PackageName
,LoadTime
,NumberofRecords
,Status1
,Status2
) VALUES(?,?,?,?,?)
4. Click the Parameter Mapping tab of the Execute SQL Task, and set the parameter mapping as follows (supposing all the columns in the PkgAudit table use varchar data type):
Regards,
Mike Yin
TechNet Community Support

Similar Messages

  • How to use row count as the starting point for a sequence

    I want to create a sequence, which starts with the row count on a table. I used the following, but it's not correct. Please help.
    CREATE SEQUENCE "PARTY_POC_S" MINVALUE 1 MAXVALUE 2000000000 INCREMENT BY 1 START WITH
    (select count(*) from "S_PARTY") CACHE 20 NOORDER NOCYCLE ;

    may be someting like this
    NOT RECOMMENDED
    DECLARE
      stCount               NUMBER;
    BEGIN
      SELECT COUNT (*)
        INTO stcount
        FROM S_PARTY;
      EXECUTE IMMEDIATE    'CREATE SEQUENCE PARTY_POC_S MINVALUE 1 MAXVALUE 2000000000 INCREMENT BY 1 START WITH '
                        || stcount
                        || ' CACHE 20 NOORDER NOCYCLE';
    END;

  • How to get row count(*) for each table that matches a pattern

    I have the following query that returns all tables that match a pattern (tablename_ and then 4 digits). I also want to return the row counts for these tables.
    Currently a single column is returned: tablename. I want to add the column RowCount.
    DECLARE @SQLCommand nvarchar(4000)
    DECLARE @TableName varchar(128)
    SET @TableName = 'ods_TTstat_master' --<<<<<< change this to a table name
    SET @SQLCommand = 'SELECT [name] as zhistTables FROM dbo.sysobjects WHERE name like ''%' + @TableName + '%'' and objectproperty(id,N''IsUserTable'')=1 ORDER BY name DESC'
    EXEC sp_executesql @SQLCommand

    The like operator requires a string operand.
    http://msdn.microsoft.com/en-us/library/ms179859.aspx
    Example:
    DECLARE @Like varchar(50) = '%frame%';
    SELECT * FROM Production.Product WHERE Name like @Like;
    -- (79 row(s) affected)
    For variable use, apply dynamic SQL:
    http://www.sqlusa.com/bestpractices/datetimeconversion/
    Rows count all tables:
    http://www.sqlusa.com/bestpractices2005/alltablesrowcount/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How to use a counter to build a Logic Analyzer?

    Hi guys, i have heard that we can use a counter as a Logic Analyzer based on an incoming signal and its clock frequency. Anyone know how this works?
    I am trying to read a set of signals, which I have no knowledge of  except that there would a Clock, reset and a data line; and I want to develop a Logic Analyzer to 'know' these signals.
    Thanks, Anoop
    Solved!
    Go to Solution.

    Lynn,
    I have a PXI-7813R, which along with its FPGA is sufficient I believe for this purpose.
    How many digital signals do you need to examine simultaneously?
    Well, I am not sure, but based on the signals generated by similar devices, I would guess between 4 and 6. I expect there to be a Clk, Rst, Data and some other signals.
    What is the maximum frequency?
    I have no idea or how to even come up with a guess on this one.
    What is the maximum and minimum number of samples per signal that you need to capture?
    Again, not a clue. Would it not depend on the Clk frequency?
    Are any of the signals ever in a high impedance (tri-state) mode?  
    Again, don't know, sorry.
    Is the minimum pulse width for non-clock signals the clock period, half the clock period, or something else?
    Sorry again.
    How would you go about in this situation?

  • How to use SAXParser to transform using stylesheet

    I've got some PL/SQL code that is generating in-memory XML
    document based on query run against Oracle database, and then
    transforms that XML using XSLT (for later posting over network).
    I've been encountering lots of memory errors and wanted to try
    using the SAXParser instead. However, the info I've found on
    SAXParser never really talks about transforming using stylesheet.
    How would I go about transforming a 'subdocument' at a time (I
    need the output to exist as one very large properly formatted XML
    document, not as a bunch of separate XML docs). Are there
    examples of this somewhere?

    Hi. What I understand is, you should pass the value of the body first on a variable before doing the MFL transformation action. Use the Assign action to do this.
    Then Use the MFL transform on the value inside the given variable, and you can pass it back to body.

  • How to use 'Extract Values' transformation?

    Hi,
    I am new to EDQ. I have the following requirement - source system sends me partyname+address details. I need to check in the oracle database and if there is a match then send back the ID along with the input details. I am using Lookup check audit process to check if the data is present in the database. If the data is present then I need to send back the ID. To extract the ID I am using 'Extract Values' transformation. I am not able define the Reference Data for this . Can provide a example how to use the same.
    Thanks
    Prabha

    Just use Lookup and Return.
    Though it sounds like you really should be using a match process.

  • How to uses setOutputProperties of Transformer

    Hi all,
    I am using javax.xml.transform.Transformer class to write out DOM to XML File. But I dont know how to use the function setOutputProperties of this class. Could you show to me an example, please?
    Thanks a lot
    have a nice day
    dsea00

    Hi all
    I just found:
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "REPORT write by DSEA");
    see import javax.xml.transform.OutputKeys; for detail
    thanks anyways
    dsea

  • How to include row count in report

    I have a report which shows list of available classes for students to register. One table called reg (which is not included in the report) keeps student_id and class_id numbers so that we know who signed up for which class.
    I'd like to count rows in the reg table and group them by classid and then include results in the report so that we know how many students already signed up for each class. How can I do that?

    I assume that you are providing the report with some SQL to pull in the available classes. Why don't you put in a sub select where you are doing a count on the other table?
    So for example,
    SELECT a.CLASSID, a.CLASSNAME, (SELECT COUNT(*) FROM STUDENTS where CLASSID = a.CLASSID ...Your group by, etc...) as Current FROM CLASSES

  • How to use existing plugin transformation from a new plugin

    Hi,
    Begginer's question:
    I use the SDK examples for a new plugin I want to write.
    I want to invoke several commands of an existing plugins from my plugin.
    For example I define a new Effect Control: My Opacity. For start I would like to invoke the functionality of Transform->Opacity.
    Now, I saw in the example Projector that I can invoke
    suites.EffectSuite2()->AEGP_ApplyEffect
    Is this the way to do it?
    How can I pass the parameter that the user gave me to the needed effect?
    I guess rhere is a quicker way to find the effect by name instead of iteration on all available as done in the Projector example.
    Thanx in advance,
    Miro

    Hello miro A, welcome to the forum!
    i'm having some trouble understanding the process you're creating, so i have a couple of questions:
    1. is your effect a layer effect? (like "gaussian blur")
    or is it a general plug-in? (like layer->transform->fit vertical, or the "wiggler" panel)
    the two (effects and AEGPs) differ in many ways and will determine the way you approach the problem.
    2. when you say "the parameter that the user gave me", what do you mean?
    is there a standard slider on your effect that the user can manipulate?
    in the mean time i'll do my best to answer you questions:
    yes, suites.EffectSuite2()->AEGP_ApplyEffect() is the way to add a new effect to a layer,
    BUT if your effect is a layer effect (again, like "curves"), then you're in for some major problems.
    layer effects can't add new effects to the same layer as themselves.
    it causes errors and crashes, because by the time your effect returns from it's call AE discovers that the layer has changed in the mean time (you added an effect), and AE doesn't cope with that change well. at all.
    no, there is no way of knowing what effect to access on a layer without iterating through them at some point in time.
    to access an effect you must retrieve an effectRef.
    to get an effectRef you must call it's index on a layer, along with the identifier of a specific layer. (layerH and effect index on that layer (say... 3rd effect))
    to know the index, you must iterate though the effects on a layer and check each one for it's name or matchName.
    you don't have to do it every time.
    you can store the index for later use, but keep in mind that the user might move effects around,
    so make smart decisions.
    wait. it gets worse.
    now you want to affect a parameter on a different effect.
    that can be done using streamRefs. these refer to the different parameters on all effects.
    once you obtain the streamRef of a wanted parameter, you can read it or write to it.
    to get a param's stream ref on an effect for which you already have an effectRef, you must know it's index in the effect. (for example, the "blurriness" on "gaussian blur" is 1 (never 0. zero is the input buffer))
    the index is not always what it seems. there may be hidden params (and other stuff in the way).
    the param index might change if the vendor of the other effect decides to change it.
    in short:
    yes, it's as complex as you feared it would be, and as you saw in the "projector" sample.

  • IP - Problem in FOX formula: how to use 0FISCPER3 counter of a DO function?

    Hi,
    IP 7.0:
    I'd like to define a top-down function which distributes the values in 0FISCPER3 = # to the periods selected by the user with two variables (period from and period to variable).
    -> Problem I experience is the conflict in different data types. How can I use the value of the selection variable for 0FISCPER3 in a counter of a DO function. Here is the code:
    formula example:
    change the value of the keyfigure ZQUANTITY of PRODUCT11
    to the value of ZQUANTITY of PRODUCT09 times 1.1
    assumption for fields to be changed: ZPRODUCT
                     ==> operand: {name of keyfigure, ZPRODUCT}
      DATA L_FACTOR TYPE F.
      L_FACTOR = 1.1.
      { ZQUANTITY, PRODUCT11 } = { ZQUANTITY, PRODUCT09 } * L_FACTOR.
    DATA LV_COUNTER TYPE 0FISCPER3.
    DATA LV_PERIODS TYPE  0FISCPER3.
    DATA LV_PERIOD_FROM TYPE 0FISCPER3.
    DATA LV_PERIOD_TO TYPE 0FISCPER3.
    *Transfer variable period from and period to into local variable and count interval of periods.
    LV_PERIOD_FROM = VARV(Z_PERIOD_FR).
    LV_PERIOD_TO = VARV(Z_PERIOD_TO).
    LV_PERIODS =  LV_PERIOD_TO - LV_PERIOD_FROM.
    Do top-down distribution for all adjustment values on period = #
    LV_COUNTER = (LV_PERIOD_FROM).
    DO.
    <b> { 0G_QVVGRM, LV_COUNTER} = { 0G_QVVGRM, # } / LV_PERIODS.</b>
    <b> LV_COUNTER =  LV_COUNTER + 1.</b>
        IF LV_COUNTER >= LV_PERIOD_TO.
            EXIT.
      ENDIF.
    ENDDO.
    -> the lines indicated in bold give errors. If I change the datatype of LV_COUNTER to I, how to start the do function the value of the first period selected by the user?
    function TMLV is also not supported apperantly in IP.
    Help would be very appreciated
    regards
    D

    Small extension:
    function TMVL does work, but I still have the problem to use the difference in periods solely for calculation in a key figure. I cannot switch from type 0FISCPER into F or I. In SAP R/3 ABAP this is no problem but apperantly in FOX it is???
    Hereby revised coding:
    DATA LV_COUNTER TYPE I.
    DATA LV_PERIODS TYPE  0FISCPER3.
    DATA LV_PERIOD_FROM TYPE 0FISCPER3.
    DATA LV_PERIOD_TO TYPE 0FISCPER3.
    DATA LV_FISCPER3 TYPE 0FISCPER3.
    *TRANSFER VARIABLE PERIOD FROM AND PERIOD TO INTO LOCAL VARIABLE AND COUNT INTERVAL OF PERIODS.
    LV_PERIOD_FROM = VARV(Z_PERIOD_FR).
    LV_PERIOD_TO = VARV(Z_PERIOD_TO).
    LV_PERIODS =  LV_PERIOD_TO - LV_PERIOD_FROM.
    DO TOP-DOWN DISTRIBUTION FOR ALL ADJUSTMENT VALUES ON PERIOD = #
    LV_COUNTER = 0.
    DO.
      LV_FISCPER3 = TMVL(LV_PERIOD_FROM,LV_COUNTER).
    <b>{ 0G_QVVGRM, LV_FISCPER3} = { 0G_QVVGRM,#} / LV_PERIODS.</b>
    { 0G_QVVGRM,#} = { 0G_QVVGRM,#} - { 0G_QVVGRM, LV_FISCPER3}.
    IF { 0G_QVVGRM, #} < 0.01.
    EXIT.
    ENDIF.
    LV_COUNTER = LV_COUNTER + 1.
    ENDDO.
    ERROR: conflict between operation type F and 0FISCPER3

  • How to get row count of a sql query

    After firing a query, how can i get the number of records returned by the query from the database, it should be database indipendent.
    Statement stmt = conn.createStatement();
                      stmt.executeQuery(query);After this I want the number of row i.e. the number of records returned by the database.

    Number of rows in a ResultSet may be obtained with:
    ResultSet rs;
    int numRows=rs.last().getRow();
    I would have said this too, as a matter of fact I mentioned scrollable result sets in my post, but as I said, not all drivers support this, and he said he needed it to be database independent, so this method should not be used.

  • How to use row values in Presentation or Administration for calculation

    Hi All,
    I am working on OBIEE, I want to calculate / or % on two rows.
    e.g. In my report row 3 is value 20 and row 5 is value 200.
    In same column row 6 I want to display *(row 5 / row 3 )* 200/ 20 i.e. output should be 10.
    Else can I use variable to and assign value to variable.
    I tried but giving error :
    CASE
    WHEN "Report Structure".Seq = 101 and Currency.Code = 'SAR' THEN
    "Fact Report"."Actual PTD" ,
    VALUEOF("col10") = "Fact Report"."Actual PTD"
    ELSE "Fact Report"."Actual PTD"
    END
    I am trying to store row value to repository variable to solve above problem.
    My question is how to assign value to variable.
    Please guide me to solve this problem.
    Thanks In advance
    Regards
    Dixit

    When you want to compare two row values, you can use the lag and lead analytical function of oracle.
    lag and lead are analytical functions that can be used to get the value of a column in a previous/next row.
    I have made just an example on my blog for a period to period comparison on OBIEE
    http://gerardnico.com/weblog/2009/04/17/obiee-period-to-period-comparison-with-the-analytical-function-laglead/
    And if you want an example on Oracle :
    http://gerardnico.com/wiki/dw/analytic_function/analytic_function_lag
    But I don't understand completely your problem. What about the row 1, 2, 4 ? I don't really see you report.
    What I see, is that you have a problem with the currency.
    You say :
    I am trying to store row value to repository variable to solve above problem.For me, it's not possible...
    Success
    Nico

  • How to use counter as an start and stop trigger in 6009

    Hi ALL.
    I'm using USB 6009 as a subject of to acquire data.
    I would like to know on how to use the counter digital input as a start and stop trigger. 
    The acquisition will only start when the first pulse of the digital signal is received and it will stop when the desired number of pulse is received.
    I was trying to use the VI as attachment as my reference. However, after tried, the VI is not working for USB 6009 as the counter input cannot be used as a trigger.  
    I would be happy if anyone could suggest me some ideas on this matter.
    Thanks.
    Attachments:
    DigitalStartandStopTrigger.vi ‏32 KB

    Hi Kate. 
    Thanks for your response.
    For your information, I've design my VI using the counter method. However, it doesnt work well. Please see the figure below. The file also attached with this reply.
     At first, the first counter from Device 2 will start counting. If the counting equal 0, then the acquisition for Device 1/AIO also the counter of Device 1/ctr0 begin acquiring data and counting the edges respectively.
    However, when I did the test, it doesn't work as wanted. It is happened because when counter of device 2 in not equal to 0, the acquisition for Device 1 not happened as it will go to false state.
    Is there anything that someone could suggest on how to start the acquisition for device 1 only and if the counter of device 2 is equal to 1. I would like the acquisition of device 1 start only when the counter of device 2 is equal to 1. I cannot use the trigger as 6009 is not support for it. 
    -Fird- 
    Message Edited by Fird on 07-02-2009 04:28 AM
    Attachments:
    Acquire Data Test 4.vi ‏27 KB

  • SSISB Row Counts in SQL Server 2012

    Does SSISDB (SQL Server 2012) track row counts such as total rows loaded, inserted rows, and updated rows?
    Or do we still need to use the row count transformation to capture these counts?
    Ryan P. Casey • <a href="http://www.R-P-C-Group.com">www.R-P-C-Group.com</a>

    Hi RPCASEY001,
    Based on my research, Row Counts for Execute SQL Task do not get captured in [SSISDB].[internal].[execution_data_statistics] table even when logging on the SSISDB server is set to Verbose. As per my understanding, this makes sense that how would SSIS know
    what the affected row counts are by the SQL statement in an Execute SQL Task given that we can put whatever we want in there?
    If we want to capture row counts loaded using the Execute SQL task, we can create a log table and add the row counts column into the log table. For more details, please refer to the following blog:
    http://consultingblogs.emc.com/jamiethomson/archive/2005/06/11/SSIS_3A00_-Custom-Logging-Using-Event-Handlers.aspx
    The following similar thread is for your reference:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/64ab1ec3-b0f2-4bba-9523-a7bcd6c154f1/ssis-logging-recording-record-count-from-sql-task?forum=sqlintegrationservices
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

  • Answers: total row count

    Ist it possible to print the total row count on the first or each page?
    Regards,
    Stefan

    I am relatively new to Answers. How do use row level count function?

Maybe you are looking for