Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6243311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:07:01+00:00 2026-05-24T12:07:01+00:00

I have a row count component that uses a global variable X to store

  • 0

I have a row count component that uses a global variable X to store the number; up to this point it rules but then if I add a script component that has X among its ReadOnly variables and then use it inside it for some purpose, the flow hangs on for a moment then it crashes saying row count needs a valid variable.

Isn’t it possible to store the row count in a variable and then read this variable from a script comp. ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:07:01+00:00Added an answer on May 24, 2026 at 12:07 pm

    You can not use a variable you populate in a Row Count transformation anywhere else in that same data flow. In the PreExecute phase of the data flow, the Row Count locks the variable. Attempting to use the variable in a Script component would have the Script try the same thing (at the same time) and SSIS therefore throws an error.

    But even if that didn’t happen, here’s what else is going on. As your data flow works, and rows pass into the Row Count, it isn’t actually filling the SSIS variable with the row count. That would be very inefficient, since the Row Count is actually a COM component and the SSIS variables are .Net. It’s “expensive” to use .Net resources from COM and vice-versa. So the Row Count accumulates the value in a local code variable. In the PostExecute phase, the Row Count then pushes the value it collected into the SSIS variable. The key point is that the PostExecute phase happens after the data flow is complete. If you were able to view the variable at any time during the middle of the data flow (there are ways) you would see it valued at zero (or whatever value it was set to before the data flow started).

    If you want to use a count of rows to perform a conditional action, or update rows within the flow, you have a couple choices:

    • You can split the data flow into two data flows. Use a RAW file or SQL table to persist the “in-progress” data at the end of flow #1 so you can use it at the start of flow #2.
    • You can use a Multicast to duplicate the flow, an Aggregate component to count it, and then do a cross-join to put the row count onto each row. (See Performing a Cross-Join (Cartesian Product) in SSIS.)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a row of data that I need to modify in a database,
I have a MySQL table that will only have one row. What should my
I have a 5 million row table that gets hit with a specific query
I have GridView which I can select a row. I then have a button
I have a core data based app I am working on, that uses an
I have this XML file that I parse into its elements and create a
MS SQL Server doesn't have row level triggers, correct? If I needed to insert
I have a row of buttons, which all create a pdf file which I
If I have records: Row Date, LocationID, Account 1 Jan 1, 2008 1 1000
Say I have an ID row (int) in a database set as the primary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.