Assiging stored procedure results to SSIS variable I am trying to get the value from a stored procedure into an SSIS variable, and then testing to see if two SSIS tasks can work if I added an expression. So for an example, I am trying to use this stored procedure: 



Maybe I am even setting up the SSIS variable properties entirely wrong, because I am also not sure if I am doing this the right way for the stored proc value to be imported into an SSIS variable. Please do tell me if you need any more screencaps of anything else.

Here is the task example:



And here is Precedence Constraint Editor screencap:



And here is the properties for the first task:



I want it to go forward (or fail) based on that condition. But when I test it, the process flows from first task to second regardless, and only shows me "100% complete" for the first task and nothing about whether it checked this expression to be true or not. How can I do such a thing and what is going wrong? 
I do have a variable in SSIS called 'orderCount' to get the value from stored proc.
You have two choices to make this work. Either you can use a Single Result Set or you can use the OUTPUT parameter. You're currently using neither correctly.

OUTPUT parameter

Your stored procedure is defined as having a parameter of @OrderCount with a direction of OUTPUT

If you wanted to use the stored procedure within a tool, SSMS, .NET, whatever, it'd look something like

DECLARE @orderCount int = 0;
EXECUTE dbo.TestStoredProcSSVariable @orderCount OUTPUT;
SELECT @orderCount As OrderCountVariable;


It is valid to run the above without specifying OUTPUT but look at the value of @orderCount. It changes from 1435 to 0.

The same holds true when you're using the Execute SQL Task within SSIS. You must specify that the parameter is on OUTPUT and also specify it in the Parameter mappings tab. 



Also specify the variable you want to map and use the OUTPUT direction there. Here I've mapped the result into an SSIS Variable of type Int32 called orderCount



Single Result Set

You have the first part of this correct - you've specified that the result set is Single Row.

You'll note that I am using EXECUTE dbo.TestStoredProcSSVariable ? as you must specify an input value or the proc call will break (at least as you've defined it). You could have hard coded a value in lieu of the ? like 0



Then, on the Result Set tab, here I'm mapping up the first column (zeroth ordinal) to a Variable called orderCountb



If you run the provided stored procedure, you will not get a value in orderCountb. Why? Because you aren't returning anything from the stored procedure call. I added a final statement inside the stored procedure of 

SELECT @OrderCount AS OrderCount;


Do it yourself

You can explore either approach using the following biml. What is biml? The Business Intelligence Markup Language is the operating system for BI. Why you care about it is that it will allow you to transform some XML into an SSIS package. All you need to do is download and installed the free addon BIDS Helper

After installing BIDS Helper,


Right click on the project and select Add new Biml file
replace the contents of the file with the following XML
Fix the values in line 5. Update the Data Source to a real server and Provider to align with your SSIS version. Looking at your screenshot, this will likely be SQLNCLI10.1
Right click on BimlScript.biml and choose Generate SSIS Packages


Bimlscript.biml

&lt;Biml xmlns="http://schemas.varigence.com/biml.xsd"&gt;
    &lt;Connections&gt;
        &lt;Connection
            Name="tempdb"
            ConnectionString="Data Source=.\dev2014;Initial Catalog=tempdb;Provider=SQLNCLI11.1;Integrated Security=SSPI;"
            /&gt;
    &lt;/Connections&gt;
    &lt;Packages&gt;
        &lt;Package
            Name="dba_114775"
            ConstraintMode="Linear"
        &gt;
            &lt;Tasks&gt;
                &lt;ExecuteSQL
                    ConnectionName="tempdb"
                    Name="SQL Make procedure"&gt;
                    &lt;DirectInput&gt;
                        &lt;![CDATA[IF EXISTS
(
    SELECT
        *
    FROM
        sys.procedures AS P 
        INNER JOIN 
            sys.schemas AS S
            ON S.schema_id = P.schema_id
    WHERE
        S.name = 'dbo'
        AND P.name = 'TestStoredProcSSVariable'
)
BEGIN
    DROP PROCEDURE dbo.TestStoredProcSSVariable
END
GO
CREATE PROCEDURE dbo.TestStoredProcSSVariable
(
    @OrderCount int OUTPUT
)
AS
BEGIN
    SET NOCOUNT ON;

    SET @OrderCount = 1135;
    SELECT @OrderCount AS OrderCount;
END

GO

]]&gt;
                    &lt;/DirectInput&gt;

                &lt;/ExecuteSQL&gt;
                &lt;Container Name="SEQC Result set" ConstraintMode="Linear"&gt;
                    &lt;PrecedenceConstraints&gt;
                        &lt;Inputs&gt;
                            &lt;Input OutputPathName="SQL Make procedure.Output"&gt;&lt;/Input&gt;
                        &lt;/Inputs&gt;
                    &lt;/PrecedenceConstraints&gt;
                    &lt;Tasks&gt;
                        &lt;ExecuteSQL
                              ConnectionName="tempdb"
                              ResultSet="SingleRow"
                              Name="SQL SingleRow"&gt;
                            &lt;DirectInput&gt;EXECUTE dbo.TestStoredProcSSVariable ?;&lt;/DirectInput&gt;
                            &lt;Results&gt;
                                &lt;Result VariableName="User.orderCountb" Name="0" /&gt;
                            &lt;/Results&gt;
                            &lt;Parameters&gt;
                                &lt;Parameter DataType="Int32" VariableName="User.orderCountb" Name="0" /&gt;
                            &lt;/Parameters&gt;
                        &lt;/ExecuteSQL&gt;
                        &lt;ExecuteSQL ConnectionName="tempdb" Name="SQL Placeholder"&gt;
                            &lt;DirectInput&gt;SELECT 1;&lt;/DirectInput&gt;
                        &lt;/ExecuteSQL&gt;
                        &lt;ExecuteSQL ConnectionName="tempdb" Name="Execute SQL Task 2"&gt;
                            &lt;DirectInput&gt;SELECT 1;&lt;/DirectInput&gt;
                            &lt;PrecedenceConstraints&gt;
                                &lt;Inputs&gt;
                                    &lt;Input 
                                        OutputPathName="SQL Placeholder.Output" 
                                        EvaluationOperation="ExpressionAndConstraint" 
                                        EvaluationValue="Success" 
                                        Expression="@[orderCount] &amp;lt; 5" /&gt;
                                &lt;/Inputs&gt;
                            &lt;/PrecedenceConstraints&gt;
                        &lt;/ExecuteSQL&gt;
                    &lt;/Tasks&gt;
                &lt;/Container&gt;
                &lt;Container Name="SEQC Output Parameter" ConstraintMode="Linear"&gt;
                    &lt;PrecedenceConstraints&gt;
                        &lt;Inputs&gt;
                            &lt;Input OutputPathName="SQL Make procedure.Output"&gt;&lt;/Input&gt;
                        &lt;/Inputs&gt;
                    &lt;/PrecedenceConstraints&gt;
                    &lt;Tasks&gt;
                        &lt;ExecuteSQL
                              ConnectionName="tempdb"
                              Name="SQL Output parameter"&gt;
                            &lt;DirectInput&gt;EXECUTE dbo.TestStoredProcSSVariable ? OUTPUT;&lt;/DirectInput&gt;
                            &lt;Parameters&gt;
                                &lt;Parameter 
                                    DataType="Int32" 
                                    VariableName="User.orderCount" 
                                    Name="0" 
                                    Direction="Output" /&gt;
                            &lt;/Parameters&gt;
                        &lt;/ExecuteSQL&gt;
                        &lt;ExecuteSQL ConnectionName="tempdb" Name="SQL Placeholder"&gt;
                            &lt;DirectInput&gt;SELECT 1;&lt;/DirectInput&gt;
                        &lt;/ExecuteSQL&gt;
                        &lt;ExecuteSQL ConnectionName="tempdb" Name="Execute SQL Task 2"&gt;
                            &lt;DirectInput&gt;SELECT 1;&lt;/DirectInput&gt;
                            &lt;PrecedenceConstraints&gt;
                                &lt;Inputs&gt;
                                    &lt;Input 
                                        OutputPathName="SQL Placeholder.Output" 
                                        EvaluationOperation="ExpressionAndConstraint" 
                                        EvaluationValue="Success" 
                                        Expression="@[orderCount] &amp;lt; 5" /&gt;
                                &lt;/Inputs&gt;
                            &lt;/PrecedenceConstraints&gt;
                        &lt;/ExecuteSQL&gt;

                    &lt;/Tasks&gt;
                &lt;/Container&gt;
                &lt;ExecuteSQL ConnectionName="tempdb" Name="SQL Placeholder"&gt;
                    &lt;DirectInput&gt;SELECT 1;&lt;/DirectInput&gt;
                    &lt;PrecedenceConstraints&gt;
                        &lt;Inputs&gt;
                            &lt;Input OutputPathName="SEQC Result set.Output" /&gt;
                            &lt;Input OutputPathName="SEQC Output Parameter.Output" /&gt;
                        &lt;/Inputs&gt;
                    &lt;/PrecedenceConstraints&gt;
                &lt;/ExecuteSQL&gt;
            &lt;/Tasks&gt;
            &lt;Variables&gt;
                &lt;Variable DataType="Int32" Name="orderCount"&gt;-1&lt;/Variable&gt;
                &lt;Variable DataType="Int32" Name="orderCountb"&gt;-1&lt;/Variable&gt;
            &lt;/Variables&gt;
        &lt;/Package&gt;
    &lt;/Packages&gt;
&lt;/Biml&gt;


Enjoy the following SSIS package