Find all spatial data columns in SQL Server database

Spatial in SQL Server are columns with the following data types: geometry, geography

The query below lists all columns with spatial data types.


select schema_name(t.schema_id) + '.' + as [table],
       c.column_id, as column_name,
       type_name(user_type_id) as data_type
from sys.columns c
join sys.tables t
     on t.object_id = c.object_id
where type_name(user_type_id) in ('geometry', 'geography')
order by [table],


  • table - name of the (schema and table
  • column_id - column position in table
  • column_name - name of the column
  • data_type - type of spatial data:


  • One row represents one column with a spatial data type
  • Scope of rows: all columns containing spatial data types in the database
  • Ordered by schema name, table name and column position in table

Sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
There are no comments. Click here to write the first comment.