sp_help_spatial_geography_histogram (Transact-SQL)

SQL Server 2012

Facilitates the keying of grid parameters for a spatial index.

sp_help_spatial_geography_histogram [ @tabname =] 'tabname' 
     [ , [ @colname = ] 'columnname' ] 
     [ , [ @resolution = ] 'resolution' ]
     [ , [ @sample = ] 'tablesample' ]

[ @tabname =] 'tabname'

Is the qualified or nonqualified name of the table for which the spatial index has been specified.

Quotation marks are required only if a qualified table is specified. If a fully qualified name, including a database name, is provided, the database name must be the name of the current database. tabname is sysname, with no default.

[ @colname = ] 'columnname'

Is the name of the spatial column specified. columnname is a sysname, with no default.

[ @resolution = ] 'resolution'

Is the resolution of the bounding box. Valid values are from 10 to 5000. resolution is a tinyint, with no default.

[ @sample = ] 'sample'

Is the percentage of the table that is used. Valid values are from 0 to 100. tablesample is a float. Default value is 100.

A table value is returned. The following grid describes the column contents of the table.

Column name

Data type




Represents the Unique ID of each cell, with a starting count of 1.



Is a rectangular polygon that represents each cell. Cell shape is identical to the cell shape used for the spatial indexing.



Indicates the number of spatial objects that are touching or containing the cell.

User must be a member of the public role. Requires READ ACCESS permission on the server and the object.

SSMS spatial tab shows a graphical representation of the results. You can query the results against the spatial window to get an approximate number of result items.

Note Note

Objects in the table may cover more than one cell, so the sum of the cells in the table may be larger than the number of actual objects.

The bounding box for the geography type is the entire globe.

The following example calls sp_help_spatial_geography_histogram on the Person.Address table in AdventureWorks2012 database.

USE AdventureWorks2012


ALTER DATABASE AdventureWorks2012



EXEC sp_help_spatial_geography_histogram @tabname = [Person.Address], @colname = SpatialLocation, @resolution = 64, @sample = 30;


Community Additions