Take the 2-minute tour ×

I am currently working on a project in which spatial data are stored in a Microsoft SQL Server 2008 database. The tables which hold the spatial table contain 3 rows and are:

RoomId - BIGINT, 
Description - VARCHAR(40), 
Geometry - geometry.

I use QuantimGIS 1.8.0 for Windows and I use the tool for adding an MSSQL Spatial Layer. I succeed in connecting to the Server and I get a list of the tables which is as follows:

Schema: dbo
Table: tbl_lv1
Type: Polygon
Column: Geometry
Primary key column: (empty)
Select at id: checked
Sql: (empty)

And when I click add, I get the following error:

dbname='gis' host='CAPDEV' user='qgisuser' password='*********' srid=0 type=POLYGON table="dbo"."tbl_lv1"(Geometry) sql= is an invalid layer and cannot be loaded

Why is this happening? Am I missing something?

Thank you

Solved: The solution was to add an auto-increment identifier to use as a primary key, because QuantumGIS needs a primary key attribute in order to import data.

share|improve this question
Here it seems that is an already-solved bug: hub.qgis.org/issues/5407 Maybe you can check this URL to see if you get any idea. If not, I would check very carefully syntax, quotations are VERY tricky or check if you have to specify on the command a PORT number to connect... –  iamgin Dec 10 '12 at 13:15
Can you paste the full schema of your table? –  Nathan W Dec 23 '12 at 10:24
You might want to post your solution as an answer to the question and accept it. That way, other people will know that your case has been resolved. –  R.K. Dec 23 '12 at 12:57
add comment


Your Answer



Browse other questions tagged or ask your own question.