Toon posts:

SQL 7, DTS package, parameter meegeven

Pagina: 1
Acties:

Verwijderd

Topicstarter
Tweakers,

Ik zoek een manier om aan mijn DTS package binnen SQL7 een parameter mee te geven.

De bedoeling is dat er op basis van de usernaam die wordt meegegeven een bepaald aantal records in een andere tabel wordt toegevoegd.

Ik hoop dat iemand van jullie mij hiermee kan helpen.

Ik heb dus een package met als naam UserspecificDTS en die wil ik aanroepen met een bepaalde paramter.

Help!!

Chopper

Verwijderd

Ik weet wel dat als je rechts klikt op je package en dan voor properties kiest dan kan je daar bij een tabje parameters opgeven.

Verder staat dit ongetwijfeld ook in de online books :).

kan je trouwens niet gewoon 'exec packagenaam param1, param2' doen:?

Verwijderd

Topicstarter
Ik kan inderdaad parameters opgeven maar ik kan nergens vinden hoe ik deze dan mbv een inputparameter kan wijzigen.

Ook in de BOL kan ik niks vinden?

  • dusty
  • Registratie: Mei 2000
  • Laatst online: 21-02 00:06

dusty

Celebrate Life!

Op maandag 25 maart 2002 09:52 schreef Chopper het volgende:
Ik kan inderdaad parameters opgeven maar ik kan nergens vinden hoe ik deze dan mbv een inputparameter kan wijzigen.
Inputparameter wijzigen, als je dat in de package wilt doen zal je er een "in/out" parameter van moeten maken ipv alleen een "in" parameter.

Voorzover ik kan zien probeer jij gewoon iets standaard van packages te doen. Probeer eens een manual.

Back In Black!
"Je moet haar alleen aan de ketting leggen" - MueR


  • Nazgul
  • Registratie: Februari 2000
  • Laatst online: 11-10-2022

Nazgul

Digital Pizza Crew

Ik heb het relevante artikeltje even opgezocht op de MSDN. (Stond nog ergens in mijn favo's)
Passing Parameters to a DTS Package

The DTSRun program does not accept any command line parameters that can be passed to the package at execution time. To pass information to a package at run-time, the parameters must be read from a file or queried from a database table programmatically.

NOTE : If SQL Server 2000 tools or a named instance of SQL Server 2000 is installed on a server that has SQL Server 7.0 installed as the default instance, the DTSRun program can accept the command line parameter /A to pass values from the command line into global variables defined in a SQL Server 7.0 DTS Package.

Here is an example of an ActiveX Script Task that reads a line from a text file to set a global variable. This global variable could then be used to modify package behavior as shown in the "Controlling Packages with Global Variables" section of this article.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Function main()
  Dim fso   'This will serve as a handle to a file system object.
  Dim ofile 'Handle for accessing a file.

    'Get a file system object for manipulation files.
    Set fso = CreateObject("Scripting.FileSystemObject")

    'Open the text file.
    Set ofile = fso.OpenTextFile("c:\test.txt")

    'Read line from the file into the global variable.
    DTSGlobalVariables("myGlobalVar").Value = ofile.ReadLine

    'Close the "parameter" file.
    ofile.Close

    Main = DTSTaskExecResult_Success
End function

The following example shows how to use an ActiveX Script task to read parameters from a SQL Server table. The code reads the value of the paramvalue column in the my_param_table and uses it to set a global variable. This example uses SQL Distributed Management Objects (DMO) to interact with SQL Server, but you can accomplish the same thing by using ActiveX Data Objects (ADO) or another data access method.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Function main()
Dim oServer      'DMO Server object.
Dim oResult     'Result set.
Dim sParamValue

    'Create a SQLDMO server object.
    Set oServer =  CreateObject("SQLDMO.SQLServer")

    ' Make a connection to the local server.
    oServer.Connect ".", "sa"

    'Select the desired row from the table.
    set oResult = oServer.Databases("pubs").ExecuteWithResults_
("select  paramvalue from  my_param_table")

    'Retrieve the first row, first column from the results.
    sParamValue = oResult.GetColumnString (1,1)

    'Set the global variable.
    DTSGlobalVariables("MyGlobalVar").Value = sParamValue

    Main = DTSTaskExecResult_Success
End function

No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.