Ver Mensaje Individual
  #4 (permalink)  
Antiguo 22/07/2005, 14:45
Avatar de Mithrandir
Mithrandir
Colaborador
 
Fecha de Ingreso: abril-2003
Mensajes: 12.106
Antigüedad: 21 años, 8 meses
Puntos: 25
Este es un extracto de los books online de sql:
Cita:
Creating and Using Global Variables
To create a global variable in a DTS package prior to package execution, use the New method of the Package2 object GlobalVariables collection. Set the Value property, and then Add the object to the collection.

Alternatively, you can create and add the GlobalVariable object to the GlobalVariables collection with the AddGlobalVariable method.

You need to create GlobalVariable objects before package execution if the ExplicitGlobalVariables property of the Package2 object is set to TRUE. However, if ExplicitGlobalVariables is set to FALSE, you do not need to create GlobalVariable objects. The package automatically creates global variables that do not exist at first reference.

Setting global variables with the ExecuteSQLTask2 object
You can create and assign values to global variables in the ExecuteSQLTask2 object. Specify a list of global variable names with the OutputGlobalVariableNames property. Values from the first row of the rowset generated by the ExecuteSQLTask2 query (specified with the SQLStatement property) are stored in the named global variables. Set the OutputAsRecordset property to store the entire rowset as a disconnected Microsoft® ActiveX® Data Objects (ADO) recordset in the global variable named first in the list.

Using global variables as input parameters
You can use global variables as input parameters for the queries of the DataDrivenQueryTask2, DataPumpTask2, ExecuteSQLTask2 and ParallelDataPumpTask objects. Specify a list of global variable names with the InputGlobalVariableNames property. For more information, see Adding DTS Query Strings.

Exporting global variables to a DTS package
Create and add global variables, as described above, to the GlobalVariables collection of the ExecutePackageTask object to export these global variables to the target package. These global variables are independent of the global variables in the GlobalVariables collection of the calling package. Use the InputGlobalVariableNames property of ExecutePackageTask to specify global variables from the collection of the package that are to be exported.

Referencing global variables in ActiveX scripts
Reference global variables in ActiveX scripts as members of the DTSGlobalVariables collection. For example, in Microsoft Visual Basic® Scripting Edition (VBScript):

DTSGlobalVariables( "GV1" ).Value

If you assign a value to the above expression and GV1 does not exist, and if the package ExplicitGlobalVariables property is not set, GV1 is created.

For more information about the GlobalVariable object and the GlobalVariables collection, see DTS Global Variables in Visual Basic.
__________________
"El hombre, en su orgullo, creó a Dios a su imagen y semejanza."
Friedrich Nietzsche