This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
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.
HRESULT Script( SQLDMO_SCRIPT_TYPE ScriptType = SQLDMOScript_Default, SQLDMO_LPCSTR ScriptFilePath = 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.
When setting the ScriptType argument specifying multiple behaviors, combine values using an OR logical operator. Use these values to set ScriptType.
Generate Transact-SQL database privilege defining script. Database permissions grant or deny statement execution rights.
Generate Transact-SQL to remove referenced component. Script tests for existence prior attempt to remove component.
Generated script is prefixed with a header containing date and time of generation and other descriptive information.
Transact-SQL creating a component is prefixed by a check for existence. When script is executed, component is created only when a copy of the named component does not exist.
SQLDMOScript_ClusteredIndexes, SQLDMOScript_NonClusteredIndexes, and SQLDMOScript_DRIIndexes combined using an OR logical operator. Applies to both table and view objects.
Individual Transact-SQL statements in the script are not delimited using the connection-specific command terminator. By default, individual Transact-SQL statements are delimited.
Include Transact-SQL privilege defining statements when scripting database objects.
Object names in Transact-SQL generated to remove an object are qualified by the owner of the referenced object. Transact-SQL generated to create the referenced object qualify the object name using the current object owner.
SQLDMOScript_ObjectPermissions and SQLDMOScript_DatabasePermissions combined using an OR logical operator.
Generate Transact-SQL creating the referenced component.
When scripting object creation for a table or user-defined data type, convert specification of timestamp data type to binary(8).
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.
Use quote characters to delimit identifier parts when scripting object names.
When setting the Script2Type argument specifying multiple behaviors, combine values using an OR logical operator. Use these values to set Script2Type.
Generate Transact-SQL script creating SQL Server Agent service jobs and alerts.
When scripting an alert, generate script creating notifications for the alert.
Generated script file uses multibyte characters. Code page 1252 is used to determine character meaning.
No scripting options specified.
Encrypt passwords with script. When specified, SQLDMOScript2_UnicodeFile must be specified as well.
Include extended property scripting as part of object scripting.
Command batch includes Transact-SQL statements creating Microsoft Search full-text catalogs.
Include security identifiers for logins scripted.
Generated script creates replication implementing triggers as system objects. Applies only when scripting replication articles.
Do not script the collation clause if source is later than SQL Server version 7.0. The default is to generate collation.
Generated script output file is a Unicode-character text file.
The Script method generates a Transact-SQL command batch that defines an existing SQL Server component. Some SQL-DMO objects, such as the Index object, support command batch generation for SQL-DMO objects that defines new components through the GenerateSQL method.
Use the GenerateSQL method when capturing object definition. Use the Script method when capturing an image of an exiting component. When using the Script method as part of an application process re-creating a component, specify SQLDMOScript_Drops in the ScriptType argument to include a drop of the existing component in the command batch.
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.