SQL Server2008 Table Space

Source: Internet
Author: User

This paper takes SQL Server2008 as an example to describe the process of converting a spatial table into a normal attribute table.

Reference: Microsoft Official SQL SERVER2008 Documentation


Demand:

Add spatial fields to the normal attribute table and dump the existing latitude and longitude coordinates in the table into spatial data to facilitate subsequent use of tools such as ArcMap to load and publish services to the data.


Solve:

    1. New Geometry Type field, named Geom

    2. Update the existing property data into the Geom field, where the latitude and longitude coordinates are assumed to be numeric for the x, y type, respectively.

      Update tablename Set Geom=geometry::stgeomfromtext (' Point (' +convert (varchar,x) + ' +convert (varchar,y) + ') ', 4326) where x is isn't null and y is not null;

      Note here to cast the numeric type with the CONVERT function to varchar.

      The database log file is full error during the update and is documented here.

      Workaround:

      Switch database to Simple recovery mode ALTER DATABASE dbname set recovery simple
      Then switch the database back to the original recovery mode alter DB dbname set recovery full

    3. Create a spatial index on the Geom field

      Create spatial index Idx_tablename_geom on TableName (Geom) with (bounding_box= (xmin=-180,ymin=-90,xmax=180,ymax=90));



SQL Server2008 Table Space

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.