Script Method (BackupDevice Object)
この機能は、将来のバージョンの Microsoft SQL Server では削除される予定です。新規の開発作業ではこの機能を使用しないようにし、現在この機能を使用しているアプリケーションは修正することを検討してください。
The Script method generates a Transact-SQL command batch that can be used to re-create the Microsoft SQL Server component referenced by the SQL Distributed Management Objects (SQL-DMO) object.
構文
object
.Script( [ ScriptType ] , [ ScriptFilePath ] ,
[ NewPhysicalLocation ] , [ Script2Type ] )as String
Parts
- object
Expression that evaluates to an object in the Applies To list.
- ScriptType
Optional. A long integer that overrides default scripting behavior as described in Settings.
- ScriptFilePath
Optional. A string that specifies an operating system file as an additional target for the generated Transact-SQL script.
- NewPhysicalLocation
Optional. A string that identifies a device by operating system name and used in place of that locating the scripted device.
- Script2Type
Optional. A long integer that overrides default scripting behavior as described in Settings.
Prototype (C/C++)
HRESULT Script(
SQLDMO_SCRIPT_TYPE ScriptType = SQLDMOScript_Default,
SQLDMO_LPCSTR ScriptFilePath = NULL,
SQLDMO_LPCSTR NewPhysicalLocation = NULL,
SQLDMO_LPBSTR ScriptText = NULL,
SQLDMO_SCRIPT2_TYPE Script2Type = SQLDMOScript2_Default);
メモ : |
---|
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
When setting the ScriptType argument specifying multiple behaviors, combine values using an OR logical operator. Use these values to set ScriptType.
Constant | Value | Description |
---|---|---|
SQLDMOScript_AppendToFile |
256 |
Object Script method only. Append to indicated output file. By default, Script method overwrites existing file. |
SQLDMOScript_Default |
4 |
SQLDMOScript_PrimaryObject. |
SQLDMOScript_Drops |
1 |
Generate Transact-SQL to remove referenced component. Script tests for existence prior attempt to remove component. |
SQLDMOScript_PrimaryObject |
4 |
Generate Transact-SQL creating the referenced component. |
SQLDMOScript_ToFileOnly |
64 |
Most SQL-DMO object scripting methods specify both a return value and an optional output file. When used, and an output file is specified, the method does not return the script to the caller, but only writes the script to the output file. |
When setting the Script2Type argument specifying multiple behaviors, combine values using an OR logical operator. Use these values to set Script2Type.
Constant | Value | Description |
---|---|---|
SQLDMOScript2_AnsiFile |
2 |
Create output file as a multibyte character text file. Code page 1252 is used to determine character meaning. |
SQLDMOScript2_Default |
0 |
Default. No scripting options specified. |
SQLDMOScript2_UnicodeFile |
4 |
Create output file as a Unicode character text file. |
Returns
A Transact-SQL command batch as a string.
解説
The NewPhysicalLocation property is a string with a maximum of 260 characters. Specify an operating system file using a UNC string or drive letter, path, and name. Specify a tape device using a UNC string. For example, the string \\Seattle1\Backups\Northwind.bak specifies a server name, directory, and file name for a backup device. The string \\.\TAPE0 specifies a server and a file device, most likely a tape, as a backup device.
メモ : |
---|
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.