다음을 통해 공유


ScriptTransfer Method

Microsoft SQL Server의 이후 버전에서는 이 기능이 제거됩니다. 새 개발 작업에서는 이 기능을 사용하지 말고, 현재 이 기능을 사용하는 응용 프로그램은 수정하십시오.

The ScriptTransfer method generates a Transact-SQL command batch that creates database objects contained in the Transfer object indicated.

구문

object
.ScriptTransfer(
Transfer
, [ ScriptFileMode ] , [ ScriptFile ] )asString

Parts

  • object
    Expression that evaluates to an object in the Applies To list.
  • Transfer
    Transfer object that defines the database object and data copy.
  • ScriptFileMode
    Optional. A long integer that overrides default scripting behavior as described in Settings.
  • ScriptFile
    Optional. A string that specifies an operating system path or file as an additional target for the generated Transact-SQL script(s) as described in Settings.

Prototype (C/C++)

HRESULT ScriptTransfer(
LPSQLDMOTRANSFER TransferSpec,
SQLDMO_XFRSCRIPTMODE_TYPE ScriptFileMode = SQLDMOXfrFile_Default,
SQLDMO_LPCSTR ScriptFilePath = NULL,
SQLDMO_LPBSTR ScriptText = NULL);

[!참고] SQL Distributed Management Objects (SQL-DMO) strings are always returned as OLE BSTR objects. A C/C++ application obtains a reference to the string. The application must release the reference using SysFreeString.

Settings

Setting the ScriptFileMode argument affects interpretation of the ScriptFile argument. When setting ScriptFileMode, use these values, setting ScriptFile as described.

Constant Value Description

SQLDMOXfrFile_Default

1

SQLDMOXfrFile_SummaryFiles.

SQLDMOXfrFile_SingleFile

2

Command batch is written to one file. Specify the file name using the ScriptFile argument. If a path is not included in the file name, the file is created in the directory indicated by the client computer environment variable TEMP.

SQLDMOXfrFile_/SingleFilePerObject

4

Command batch is written to multiple files, one file for each SQL Server component transferred. Specify a path using the ScriptFile argument. If a path is not specified, the files are created in the directory indicated by the client computer environment variable TEMP.

SQLDMOXfrFile_/SingleSummaryFile

8

Command batch is written to one file. Command batch contents are organized by object type. Specify the file name using the ScriptFile argument. If a path is not included in the file name, the file is created in the directory indicated by the client computer environment variable TEMP.

SQLDMOXfrFile_/SummaryFiles

1

Command batch is written to multiple files, one file for each kind of object transferred. For example, generate a file for user-defined data types and a separate file for tables. Specify a path using the ScriptFile argument. If a path is not specified, the files are created in the directory indicated by the client computer environment variable TEMP.

Returns

A Transact-SQL command batch as a string.

주의

Use the ScriptTransfer method to capture the database object creation statements (schema transfer) specified by a Transfer object. The command batch file(s) created can be used in another process, such as a scheduled transfer of database schema.

To use the ScriptTransfer method

  1. Create a Transfer object.

  2. Populate the object using the AddObject or AddObjectByName method.

  3. If desired, set the ScriptType and Script2Type properties to control content of the command batch file(s) generated.

  4. Call the ScriptTransfer method indicating the Transfer object created in Step 1, optionally indicating an output location or a single output file.

    [!참고] SQL-DMO object scripting methods are fully compatible with an instance of SQL Server version 7.0. However, database compatibility level affects Transact-SQL command batch contents.

    When scripting a database with a compatibility level of less than 7.0, or when scripting any of its objects, the resulting Transact-SQL command batch includes only keywords reserved by that level.

    Transact-SQL command syntax is always compliant with an instance of SQL Server 7.0. Where provided, you can use optional scripting arguments, such as SQLDMOScript2_NoFG to remove some syntax of an instance of SQL Server 7.0.

Applies To:

Database Object