Getting Count of Rows in Excel

  • I have to check the number of rows in an Excel. can it be done using an Execute SQL task?

  • Surely yes...

    --Ramesh


  • Can you please tell how it can be done?

  • 1. You have to create a variable "TotalRows" (i.e. name doesn't matter) of Integer data type and an Execute SQL Task.

    2. Set the connection property, SQLSourceType as "Direct Input", SQLStatement as "SELECT COUNT(*) FROM SomeTable" and SQLResultset to "Single Row" of SQL Task

    3. And in "Result Set" page, add a row with Result Name as "0" and select the variable "TotalRows" in variable name column.

    Now you'll have the row count in the "TotalRows" variable...

    --Ramesh


  • For that i will have to load the rows in Excel into a table.

    I was asking if you can get the count directly using the Excel?

  • ns.sharath (1/8/2009)


    For that i will have to load the rows in Excel into a table.

    I was asking if you can get the count directly using the Excel?

    No, you don't have to load any data. All you have to do is to make SQL Task to connect to the excel source. And in the source statement you have to write a query like

    SELECT COUNT(*) FROM [SheetNameInExcelFile$]

    --Ramesh


Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply