Re: Using global variable in Data Transform Task (SQL Server 2000)

Tech-Archive recommends: Fix windows errors by optimizing your registry



On 4 Giu, 16:51, TheEvilDonut <TheEvilDo...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Hello.

I have a Data Transform Task with the following in the SOURCE tab :

-----
declare @sql varchar(4000), @servername sysname
SET @servername = 'ORJ0X01'
SET @sql = 'select ora.* from OPENrowset(''MSDAORA'',' + '''' + @servername
+ '''' + ';'''';'''',''SELECT SUBSTR(NO_DISTRICT, 1, 4) AS NO_DISTRICT,
SUBSTR(NO_DETAILLANT,1, 6) AS NO_DETAILLANT,  SUBSTR(NOM_DETAILLANT, 1, 30)
AS NOM_DETAILLANT,  NO_SUCCURSALE,  ADR_NO_MUNICIPAL_LIVR AS ADR_NO_CIVIQUE,  
ADR_TYPE_RUE_LIVR AS ADR_TYPE_RUE,  ADR_NOM_RUE_LIVR AS ADR_NOM_RUE,  
ADR_POINT_CARDINAL_LIVR AS ADR_POINT_CARDINAL,  ADR_TYPE_UNITE_LIVR AS
ADR_TYPE_UNITE, ADR_NO_UNITE_LIVR AS ADR_NO_UNITE,  ADR_POSTALE_LIVR AS
ADR_POSTALE,  SUBSTR(NOM_VILLE_ADR, 1, 32) AS ADR_VILLE,  
SUBSTR(TEL_CODE_REGIONAL, 1, 3) AS TEL_CODE_REGIONAL,  SUBSTR(TEL_NO, 1, 7)
AS TEL_NO,  SUBSTR(NOM_CONTACT_MOP, 1, 32) AS NOM_CONTACT_MOP,  
SUBSTR(COALESCE(FREQUENCE_VISITE,''''0''''), 1, 1) AS FREQUENCE_VISITE,  
SUBSTR(COALESCE(JOUR_VISTE,''''00''''), 1, 2) AS JOUR_VISTE,  
COALESCE(SUBSTR(TO_CHAR(SEQUENCE_VISTE, ''''09''''), 2, 2),''''00'''') AS
SEQUENCE_VISTE,  COALESCE(SUBSTR(MODE_PAIEMENT, 1, 1),''''0'''') AS
MODE_PAIEMENT,  ''''O'''' AS IND_TERM_FACT FROM DDMO.VEXE_MOP_RD_DETAILLANT
ORDER BY NO_DISTRICT, NO_DETAILLANT'') ora inner join BRANCHOFFICE sql on
ora.NO_DISTRICT = sql.DISTRICT'

execute(@sql)
-----

I would like to assign @servername with the contents of a global variable
that I initialized previously with a Dynamic Properties Task.

Can anyone tell me how I would go around doing that?

Thank you!

Hi, i think you're misunderstanding DTS variables with T-SQL
variables.
With Dynamic Properties task you can change (and assign) the value of
a "property" of a task not the value of a T-SQL variable inside a
script.
Therefore you can change the value of script (ie, all the content of
the SQL Query pane in Source Tab of the Transformation Data task) but
not the value of the @server variable inside that script.

To accomplish what you want to do i would rather use an ActiveX to
build a dynamic sql batch. It wuold read the Servername from a Global
Variable and then combine/concatenate it in the rest of your t-sql
batch script (ie, from "declare @sql varchar [...]" to "[...]
BRANCHOFFICE sql on ora.NO_DISTRICT = sql.DISTRICT' "), and then
assign it to the property SourceSQLStatement of your Transform Data
Task either using the same ActiveX or with a separate Dynamic
Properties Task.

HTH,
M.
.



Relevant Pages

  • Re: Help - Backup not working after trying to get ISA 2004 to log to SQL
    ... On the Alias tab, ... there was an alias set up that had <servername> as the alias, ... I did a lot of restarting the SQL, WSUS and VSS services, but didn't make ... Backup log file shows this error: ...
    (microsoft.public.windows.server.sbs)
  • Re: Dynamic Query Order in DTS
    ... are you using the Dynamic Properties task for something else because you do ... Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) ... >> I support PASS - the definitive, global community ...
    (microsoft.public.sqlserver.dts)
  • Re: newbie Frage zu Server-Explorer - Datenverbindungen
    ... "Microsoft SQL Server " an. ... Ich könnte den Firewall wohl ausschalten, da die Maschine via Proxi ins Netz geht. ... Ich versuche doch nur - lokal innerhalb meiner eigenen Machine - auf der ich als Admin arbeite - hinzubekommen, dass der Servername (oder meinetwegen auch lokal oder was angezeigt wird. ... Im SQL Server Configuration Manager habe ich Shared Memory, Named Pipes, UND TCP/IP Aktiviert. ...
    (microsoft.public.de.german.entwickler.dotnet.datenbank)
  • Re: Database connection problem.......I think! :-)
    ... Wit SQL is the datasource the SQL servername, not the path as you probably ... > runtime error and the handler refers to an UnauthorisedAccessException at ... > the point in code that refers to the Class where the connection is being ...
    (microsoft.public.dotnet.languages.vb)
  • newbie Frage zu Server-Explorer - Datenverbindungen
    ... WIN XP, VS Studio 2005 Pro deutsch, SQL srv 2005 Developer Edition deutsch, MSDN lib alles ganz frisch draufgespielt. ... rechte Maustaste, dann Verbindung hinzufügen, dann zeigt er mir die "Verbindungen hinzufügen" Maske. ... Ein Folgeproblem ist, dass Peter Götz Beispiel genauso wenig funktioniert, da ja der Servername dann dort auch leer ist. ... Was mich etwas irritiert ist einerseits, dass das SQL Server Management Studio diese Probleme nicht hat, und andererseits die Bezeichnung der Datenquelle "Microsoft SQL Server " ... ...
    (microsoft.public.de.german.entwickler.dotnet.datenbank)