August 15, 2011 at 8:09 am
Hi I have a sql task which executes sql commands via a variable and the storing the result set as xml.
I have a requirement, when the sql command executes, if there are o records then the package should not send out an email. If the count >0 then it should send a email by transforming the xml result set into html.
how can i calculate the count of records from the xml result set.
August 15, 2011 at 8:27 am
Please check this forum
http://www.sqlservercentral.com/Forums/Topic462732-148-1.aspx
---------------------------------------------------------------------------------------
It begins by taking the first step.
August 15, 2011 at 8:58 am
Thanks! Leju. But i dont understand the xml task path
XML Task properties:
OperationType: XPATH
SourceType: Variable
Source: User::varResults
SaveOperationResult: True
Destination: User::varRowCount
SecondOperand: count(//table1)
so in the second operand do we have to type count(//table1)
in the xml source box with operand type as direct input. If that is so then there is a problem. All the sql commands i execute have different table names.
August 15, 2011 at 9:13 am
I'll Explain it again.
I have a variable which holds all the sql commands to be executed. So in the sql task the sql source type is variable. So the sql task executes this variable and stores the data in a xml result set. then i have to transform this xml into html and send an email.
Sometimes when a sql command is executed it returns 0 records so i should set up a logic where if count > 0 then send and email.
August 15, 2011 at 11:12 pm
My recommendation would be to lookup what @@ROWCOUNT might do for you.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 18, 2011 at 1:23 pm
You could add a return value or output of the record count in the execute sql task, store that return value in a variable and then check that the value >0 in your precedence constraint. If it is greater than zero then execute the send mail task otherwise execute a different task or nothing.
MWise
August 29, 2011 at 8:22 am
Hi Jeff,
That worked for me......But in order to do that I have to write a stored proc for all the databases which they dont want to do.....
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply