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
-
does SQL server see it? I haven't needed a geometry_columns table for QGIS to read sql server tables, including editing tasks...Inactivated Account– Inactivated Account2015年10月28日 18:58:57 +00:00Commented Oct 28, 2015 at 18:58
-
Sql server sees it. That's what's crazy about it.mapman– mapman2015年10月28日 20:23:44 +00:00Commented Oct 28, 2015 at 20:23
-
1Resolved. Didn't use geometry columns table or checkbox. Made the id field an int identity (1,1) primary key.mapman– mapman2015年10月29日 22:04:33 +00:00Commented Oct 29, 2015 at 22:04
1 Answer 1
Resolved. Didn't use geometry columns table or checkbox. Made the id field an int identity (1,1) primary key.
-
ah yes! good stuff!Inactivated Account– Inactivated Account2015年10月29日 22:11:29 +00:00Commented Oct 29, 2015 at 22:11
lang-sql