Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Get Value of Variable in VB.NET Script Task Expand / Collapse
Author
Message
Posted Sunday, September 16, 2012 11:20 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Monday, September 29, 2014 10:57 PM
Points: 4,242, Visits: 4,290
I have a SQL Server Script Task.

This task queries a table and checks for the existence of a record from the current Day.

It basically returns a Row Count of Zero or 1.

The resultset variable if the Execute SQL Task is v_BasisControlRowCount.

The next task is a Script Task.

I set the v_BasisControlRowCount as a ReadWrite Variable.

I want to check the value of the variable.

If the v_BasisControlRowCount is zero I want to fail the package, if it is 1 I want the package to succeed.


Dim BasisControlRowCount As Integer = 0

BasisControlRowCount = Dts.Variables("v_BasisControlRowCount").Value


I can't remember how to do this and I'm having trouble with the syntax.

Could someone please tell me how to do this?


thanks.


For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1359903
Posted Sunday, September 16, 2012 11:41 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Monday, September 29, 2014 10:57 PM
Points: 4,242, Visits: 4,290
I remembered how to do it. That was tough.

 Public Sub Main()

Dim BasisControlRowCount As Integer = 0

BasisControlRowCount = Dts.Variables("v_BasisControlRowCount").Value

' MsgBox(BasisControlRowCount)

If BasisControlRowCount > 0 Then
Dts.TaskResult = ScriptResults.Success
Else
Dts.TaskResult = ScriptResults.Failure

End If

End Sub



For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1359904
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse