Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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: 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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.