Example: Storing a Drawing in SQL Server 2008

This topic shows a simple example of exporting a drawing into SQL Server 2008. It uses the data source created in the Example: Configuring SQL Server 2008 topic.

 

images\eg_export_dwg_sqls_01.gif

 

Launch Manifold and open the Mexico drawing used in numerous examples in the Examples chapter.

 

images\eg_export_dwg_sqls_02.gif

 

To export the drawing we choose File - Export - Drawing and in the type box choose Data Sources ().

 

images\eg_export_dwg_sqls_03.gif

 

In the resulting Data Source dialog we click the user / password pair data source set up in the prior example. This connects to the server using a specified user name and password and desired database. Press OK (or simply double-click the data source).

 

images\eg_export_dwg_sqls_04.gif

 

In the resulting Export Drawing dialog we use defaults, checking to make sure the Type is SQL Server so that we use native SQL Server 2008 spatial storage. By default, all fields (columns) will be exported except intrinsic fields. The drawing will be uploaded into the DBMS using standard Manifold geometry types and a spatial index will be created. Press OK. Done!

 

Important: When exporting a drawing to a spatial DBMS it is best if the drawing does not contain a column called OID. This name is used by Manifold as the default name for the object identity field. If we like, we can still export a drawing that contains such a column but then we will have to remember in the export dialog to change the name of the identity field to something else.

 

While that is certainly easy enough to do, it is also easy to forget to do in which case the export will fail and we will wonder why. Also, it is useful to always assume that an OID field is the identity field. Therefore, it is strongly recommended to treat this field name as a reserved name.

 

We've now saved the drawing into SQL Server 2008 spatial storage. If we want to use the drawing, we can import it from the server or link to it using the Tools - Database Console dialog as shown in topics such as the following Example: Linking a Drawing from SQL Server 2008 topic.

 

See Also

 

Data Source Dialog

Example: Configuring SQL Server 2008

Example: Linking a Drawing from SQL Server 2008

Example: Linking a Drawing from SQL Server 2008

Example: Storing a Drawing in Manifold Spatial DBMS

Example: Tracing Virtual Earth into SQL Server 2008

Multi-User Editing of Linked Drawings

Spatial DBMS Facilities

SQL Server Spatial DBMS Facilities

Tools - Database Console