MSSQL Spatial and MSSQL Azure Spatial Writer: Format Parameters
To access feature type parameters, click the gear iconon a feature type in the workspace. This opens the Feature Type Parameter Editor.
Tip:To always display the editor in Workbench, you can select View > Windows > Parameter Editor.
General
All feature types share similarGeneralparameters, which may include Feature Type Name, Reader or Writer information, and Geometry.
In most Writer Feature Type parameter dialogs, you can also controlDynamic Schema Definitions. Some database formats accept a Table Qualifier prefix on the output table feature type.
Table Settings: General
This parameter lets the user specify how features will be written into the destination table. Supported feature operations are:
- Insert:Append rows onto the destination table using attributes on features.
- Update:Update existing table columns using attributes on features. A selection method must be specified in the Row Selection group.
- 删除:删除existing table rows. A selection method must be specified in the Row Selection group.
- fme_db_operation:The feature operation will be determined by the attributefme_db_operationon each input feature. A selection method must be specified in the Row Selection group. The value offme_db_operationwill be processed as follows:
- If the value is null, empty, or missing, it will be treated as Insert.
- The value will next be matched to Insert, Update, and Delete, case insensitively.
- If there is no match, the feature will be rejected.
- If there is a match, the matched feature operation will be performed on the feature.
Tip:Thefme_db_operationattribute will now cause feature rejection when Feature Operation is set toInsert,Update, or删除. This behavior differs from previous versions of FME.
More information onFeature Operations.
Controls how the feature type handles destination tables or lists. These options are available:
- Use Existing:Write to an existing table or list. If the destination table/list does not exist, the translation will fail.
- Create If Needed:Create destination table/list if it does not exist.
- 删除和创建:Drop destination table/list if it exists, and then create it. The writer will drop and re-create the table before writing any features to it. Tables will be overwritten when the first input feature is processed. If no features are sent to a feature type, then the corresponding table will not be overwritten.
- Truncate Existing:(This option is not available for all formats.) If destination table/list does not exist, the translation will fail. Otherwise, delete all rows from existing table or list.
When updating features, users have a choice to update, or skip, their spatial column(s). Possible options are:
- Yes:The spatial column(s) specified by the user will be updated. IFMENulls will be written as null values and replace existing spatial values.
- No:No spatial columns will be updated.
When inserting into a table, Row Selection is ignored. When updating and deleting from a table (if applicable, based on a format's available Feature Operation options), a condition needs to be specified for selecting which rows to operate on. This parameter group offers two methods to construct the selection condition:
Match Columns
The columns specified in the corresponding column picker dialog will be used for matching destination rows. All matching rows will be selected for update or delete. If any feature attributes corresponding to the specified match columns contain null or missing values, the feature will be rejected.
WHERE Clause
This parameter opens aWHERE Clause Builder. You can also type a WHERE clause inline, without launching the Builder. It is optional to start the clause with the wordWHERE.
The WHERE Clause Builder makes it easy for users to reference feature attribute values, destination table columns, and invoke FME functions. The WHERE clause is first evaluated as an FME expression, before being passed onto the destination database.
If the WHERE clause is incorrect or if its evaluation results in failure, the translation will fail. Otherwise, if the WHERE clause passes FME evaluation but it is SQL invalid, the feature will be rejected or the translation will fail.
For advanced users, conditional FME expressions created through the Conditional Value editor can be used to create WHERE clauses.
Tip:You can set the WHERE Clause to an attribute. This supports workspace migration and existing workflows involvingfme_where. (Direct support forfme_wherehas been deprecated.) To advanced users who are accustomed to usingfme_where, if Feature Operation is set to Update, Delete, orfme_db_operation, anfme_where属性,反对flicts with Match Columns or WHERE Clause will result in feature rejection.
Table Creation Parameters
Note: ">Note:在本节生效只有wh的参数en FME creates a table.
This parameter specifies how a spatial index is to be created for the specified Spatial Column.
- None:No spatial index will be created for this table.
- Manual:The SQL statement specified for theSpatial Index Creation SQLparameter will be executed.
- Auto:A spatial index will be created automatically for geographies, and semi-automatically for geometries. This automation is available only on SQL Server 2012 and later with database compatibility mode of SQL Server 2012 or higher.
- Geographies: No other information is required. A bounding box can be optionally specified.
- Geometries: A bounding box is required for spatial index creation. The bounding box is specified inBounding Box (Geometry Only).
Note: ">Note:If you are using a SQL (Azure) Server whose database compatibility level is set to 2012 or higher, consider setting Spatial Index Type toAutoto avoid specifying a custom SQL. SeeSpatial Index Typeabove for details.
Due to the complexity of spatial index creation, FME lets the user specify a SQL statement to create an index on a specific spatial column in a Microsoft SQL Server Spatial table. Normally, this table would be the destination table specified by the feature type.
In the example below, a default spatial index is created on geometry columnGEOMof tablemy_table:
CREATE SPATIAL INDEX SIDX_GEOM ON my_table(GEOM) WITH (BOUNDING_BOX = (-200, -200, 200, 200))
In the example below, a spatial index is created on geography spatial columnGEOGofmy_table:
CREATE SPATIAL INDEX [SIDX_GEOG] ON my_table(GEOG) USING GEOGRAPHY_GRID WITH (GRIDS = (LOW, MEDIUM, HIGH, HIGH), CELLS_PER_OBJECT = 32)
Tip:To recreate a spatial index on an existing table, execute a SQL statement inside a SQLCreator Workbench transformer. Using the above example, the SQL statement would look like:
CREATE SPATIAL INDEX [SIDX_GEOG] ON my_table(GEOG) USING GEOGRAPHY_GRID WITH (GRIDS = (LOW, MEDIUM, HIGH, HIGH), CELLS_PER_OBJECT = 32, DROP_EXISTING=ON)
See the MSDN articleCREATE SPATIAL INDEX (Transact-SQL)for more information and examples.
These parameters together specify a bounding box for geometries,and
optionally for geographies, for spatial index creation.
- Minimum X: The x-coordinate of the bottom left corner of the bounding box.
- Minimum Y: The y-coordinate of the bottom left corner of the bounding box.
- Maximum X: The x-coordinate of the top right corner of the bounding box.
- Maximum Y: The y-coordinate of the top right corner of the bounding box.
Table Settings: Spatial
This parameter determines whether the column specified bySpatial ColumncontainsGeometryorGeographyvalues.Inherit From Writercauses the feature type to retrieve the value ofSpatial Typefrom the writer parameterSpatial Type.
This parameter specifies the name of a spatial column. If this parameter is left empty, it will inherit from the writer parameter Spatial Column.
Table Settings: Advanced
This parameter determines how FME aggregates and multi's will be interpreted and handled. Because there is not a one to one mapping between FME collections and SQL Server collections, care should be taken when input features contain spatial collections.
The optionPreserve Collection Typeswill interpret FME multi's as OGC multi's when such an interpretation is geometrically lossless, and as OGC GeometryCollections otherwise. This option preserves the collection type only. It does not promise that the resulting OGC multi or GeometryCollection will be simple or valid.
The optionSimplify Collection Typeswill interpret homogeneous FME collections as OGC multi's when such an interpretation is geometrically lossless, and GeometryCollections otherwise. It does not promise that the resulting OGC multi or OGC GeometryCollection will be simple or valid. Homogeneous FME collections refer to IFMEMulti's, and single level IFMEAggregates that can be converted into IFMEMulti's without loss of geometry.
The optionSimplify To Valid Collection Typeswill interpret homogeneous FME collections as OGC multi's when such an interpretation is geometrically lossless, and additionally when these OGC multi’s are SQL Server valid. FME collections that are SQL Server invalid are interpreted as GeometryCollections. Further:
- This option will have the effect of repairing some homogeneous collections that are SQL Server invalid. For example, if an IFMEMultiArea contains overlapping polygons that are individually SQL Server valid, then interpreting such an IFMEMultiArea as a GeometryCollection will remove the invalidity.
- This option is unable to repair homogeneous FME collections whose parts are individually SQL Server invalid.
- 这个选项考虑目的地空间列types. An FME collection that is SQL Server valid as a geometry may not be SQL Server valid as a geography, and vice-versa.
All three options are recursive; they apply to nested FME collections.
When the writer parameterHandle Multiple Spatialis set toNo, Multiple Geometries are treated as FME collections. WhenHandle Multiple Spatialis set toYes, the parts of a top-level Multiple Geometry are interpreted as distinct spatial columns, and each of these parts are handled separately.
When inserting features, this parameter determines whether or not identity columns are auto-populated.
Identity columns are columns whose values are automatically populated by the database server in sequence. This parameter allows you to override this behavior and provide the values.
There can be, at most, one identity column specified per table.
- If an identity column has been specified, the optionYespopulates the destination identity column with values from the feature attribute that corresponds to the identity column.
- The optionNocauses the destination identity column to be auto-populated by the database server.
This parameter does not affect other feature operations.
Note: ">Note:Note:Only one feature type may have this option enabled for a given MSSQL connection; all feature types within a writer share a connection, and connections may be shared between writers if they use the same connection parameters.
For more information on Identity Columns, see the Microsoft Developer Network topicIDENTITY (Property) (Transact-SQL).