Condividi tramite


TSqlObject.GetAst Method

Definition

Generates a new TSqlScript representing the AST for the TSqlObject, if this is supported for the TSqlObject. AST generation is only supported for top-level objects, with certain objects such as the DatabaseOptions and inline constraints not supporting AST generation even though they are top level types. If it's unknown whether the object is capable of being scripted then the TryGetAst(TSqlScript) method should be used instead.

The generated AST is a newly generated object that defines the information about this TSqlObject and any objects that would be scripted together with it. For example a Table would also script out the Columns and inline constraint definitions of a Table. This method can be used to copy object information from one model to another, or to script out information about objects in the model.

public Microsoft.SqlServer.TransactSql.ScriptDom.TSqlScript GetAst ();
member this.GetAst : unit -> Microsoft.SqlServer.TransactSql.ScriptDom.TSqlScript
Public Function GetAst () As TSqlScript

Returns

The generated AST object.

Exceptions

If TSqlObject is not a top level statement object or if it does not support AST generation (for example if it is a DatabaseOptions or a constraint that was originally defined inline with a Table).

Remarks

The AST will not have information about the original source position, such as the original source name and original position in an input script.

Applies to