MS SQL Spatial Layer

What Is MS SQL Spatial Layer?

MS SQL = Microsoft Structured Query Language

MSSQL Spatial Layers is a toolbar button (available in the MS SQL node in the QBrowser tree) that allows for MS SQL Server 2008 support, as well as drag and drop importing. QGIS Planet MSSQL Page

The MS SQL Spatial Tool is a driver developed by Microsoft that allows access to spatial tables in the MS SQL Server (a database management system that contains geometry and geography data that is ultimately reflected in the geometry column). In wikipedia language this means you can store and retrieve data as it's requested by other software applications, that is either on your own computer or on one connected to your same network (ie the internet). Wikipedia MSSQL Page
GDAL Page

How To Use It:

1. Ensure you’re running a version of QGIS that uses GDAL/OGR 1.8 or higher. Check the QGIS About page to see if it is supported. Also, you can look for Add MS SQL Layer in the Layer Menu.

version.png

2. Open the Python Console in QGIS and type the following:

uri = "MSSQL:server={serverName};database={databaseName};tables={tableName};trusted_connection=yes" qgis.utils.iface.addVectorLayer(uri,'{yourLayerNameHere}','ogr')

Note:

(A) Replace {serverName} with your server name. If installed on your local machine, you may use localhost.
(B) Replace {databaseName} with the name of database with the tables of choice.
(C) Replace {tableName} with the table to open.
(D) Replace {yourLayerNameHere} with the name you’d like your layer to have in the final map legend.

3. You should then see your MS SQL Spatial Table Displayed in QGIS, with editing support.
Credits:

Page by Zoe B. and Meagan T.
Edited by Phuong T.