1

enter image description here

I just created a SQL Server geometry columns table and a new table for testing in QGIS. However, QGIS still won't find the primary column in the table.

I am creating the table this way:

CREATE TABLE gis.test ( OBJECTID INT IDENTITY NOT NULL, Name VARCHAR(255), Shape GEOMETRY, CONSTRAINT [qgis_test] PRIMARY KEY CLUSTERED ( OBJECTID ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] )ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

And creating Geometry columns table this way:

 CREATE TABLE geometry_columns (
 [f_table_catalog] [VARCHAR](256) NOT NULL,
 [f_table_schema] [VARCHAR](256) NOT NULL,
 [f_table_name] [VARCHAR](256) NOT NULL,
 [f_geometry_column] [VARCHAR](256) NOT NULL,
 [coord_dimension] [INT] NOT NULL,
 [srid] [INT] NOT NULL,
 [geometry_type] [VARCHAR](30) NOT NULL,
 CONSTRAINT geometry_columns_pk PRIMARY KEY CLUSTERED
 (
 [f_table_catalog] ASC,
 [f_table_schema] ASC,
 [f_table_name] ASC,
 [f_geometry_column] asc
 )
) 
INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, geometry_type)
SELECT 
 g.f_table_catalog,
 g.f_table_schema,
 g.f_table_name,
 g.f_geometry_column,
 g.coord_dimension,
 g.srid,
 CASE WHEN g.geometry_type = 0 THEN 'Geometry'
 WHEN g.geometry_type = 1 THEN 'point'
 WHEN g.geometry_type = 2 THEN 'curve' 
 WHEN g.geometry_type = 3 THEN 'linestring'
 WHEN g.geometry_type = 4 THEN 'surface'
 WHEN g.geometry_type = 5 THEN 'polygon'
 WHEN g.geometry_type = 6 THEN 'collection'
 WHEN g.geometry_type = 7 THEN 'multipoint'
 WHEN g.geometry_type = 8 THEN 'multicurve'
 WHEN g.geometry_type = 9 THEN 'multilinestring'
 WHEN g.geometry_type = 10 THEN 'multisurface'
 WHEN g.geometry_type = 11 THEN 'multipolygon'
 END AS geometry_type 
FROM 
 sde.sde_geometry_columns g

SQL_import_error

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Oct 28, 2015 at 18:01
3
  • does SQL server see it? I haven't needed a geometry_columns table for QGIS to read sql server tables, including editing tasks... Commented Oct 28, 2015 at 18:58
  • Sql server sees it. That's what's crazy about it. Commented Oct 28, 2015 at 20:23
  • 1
    Resolved. Didn't use geometry columns table or checkbox. Made the id field an int identity (1,1) primary key. Commented Oct 29, 2015 at 22:04

1 Answer 1

1

Resolved. Didn't use geometry columns table or checkbox. Made the id field an int identity (1,1) primary key.

answered Oct 29, 2015 at 22:05
1
  • ah yes! good stuff! Commented Oct 29, 2015 at 22:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.