How do I get a count of database records?
Posted: Fri Mar 06, 2009 12:38 pm
To your project:
The snippet below shows what the project would look like:
- Add an SQL task and select the database resource you want to use.
- Add a query element, and specify the following SQL statement. For example:
select count(*) from libraryName.fileName - Specify a variable name in the Output Variable field (e.g. "data")
- Then add a Set Variable task, found in the Miscellaneous folder.
- Enter a variable name (call it "count" for now) and then using variable notation, specify column one of the rowset defined in the Output Variable above. (e.g. ${data[1]})
The snippet below shows what the project would look like:
Code: Select all
<sql resourceId="resourceName">
<query outputVariable="data">
<statement>select count(*) from table</statement>
</query>
</sql>
<setVariable name="count" value="${data[1]}" />