建立變數值檔案 (DB2ToSQL)

變數值檔案是一個 XML 檔案,其中包含命令的參數值,例如經常從一部伺服器移轉至另一部伺服器的來源或目的地伺服器名稱。 發生大量資料庫移轉時,命令列上會使用 -v 參數,在主要指令檔中建立並參考儲存每個來源伺服器值的多個變數檔案。 這有助於在幾個指令檔中維護靜態值,以及多個變數檔案中的變數值。

注意

  1. 變數名稱前綴和尾綴會加上 $ (元) 符號。 如果變數未在變數值檔案中指派值,您在剖析指令檔期間會遇到錯誤,導致主控台執行程式停止。
  2. $ 的逸出字元為 $$。 如果參數的變數值或靜態值包含 $ (元) 符號, 則必須指定 $$ 來將其視為字元,而不是變數。
  3. 為了維護性,變數可以在 'variable-group' 元素內宣告,以邏輯分隔使用者定義變數。 此元素的使用並非強制性。

範例:

範例 1:

<!--Sample of variable value file commands-->  
  
<variables>  
  
  <variable-group name="ProjectSpecs">  
  
    <variable name="$project_folder$" value="<project-folder>"/>  
  
    <variable name="$project_name$" value="<project-name>"/>  
  
    <variable name="$project_overwrite$" value="<true/false>"/>  
  
    <variable name="$project_type$" value="<project-type>"/>  
  
  </variable-group>  
  
</variables>  

範例 2:

<!--Sample of variable value file commands-->  
  
<variables>  
  
  <variable-group name="SQLServerParams">  
  
    <variable-group name="SqlServerConnectionParams">  
  
      <variable name="$TargetServerName$" value="<server-name>"/>  
  
      <variable name="$TargetDB$" value="<database-name>"/>  
  
      <variable name="$TargetUserName$" value="<user-name>"/>  
  
      <variable name="$TargetPassword$" value="<password>"/>  
  
      <variable name="$TrustedConnection$" value="<true/false>"/>  
  
    </variable-group>  
  
    <variable-group name="SqlServerObjectParams">  
  
      <variable name="$ObjectName1$" value="<object-name>"/>  
  
      <variable name="$ObjectName2$" value="<object-name>"/>  
  
    </variable-group>  
  
  </variable-group>  
  
</variables>  

後續步驟

操作主控台的下一個步驟是建立伺服器連線檔案 (DB2ToSQL)

另請參閱

建立伺服器連線檔案