Edit MSSQL Query (T-SQL)
This page explains updating a saved MSSQL query in the Pirivision Compass module via the Edit action.
Prerequisite
At least one MSSQL query must be saved in the Compass list. If none, see Create MSSQL Query first.
1. Find the Query and Click Edit
Click Compass in the left menu. On the card of the MSSQL query you want to edit, click the Edit button.
2. The T-SQL Editor Opens — Existing Query Pre-filled
The editor pre-loads the existing T-SQL query.
3. Editable Fields
| Field | Editable? | Notes |
|---|---|---|
| T-SQL Query Text | ✅ Yes | All T-SQL constructs including TOP, DATEADD, WITH (NOLOCK) are usable |
| Query Name | ✅ Yes | In the save panel |
| Description | ✅ Yes | In the save panel |
| Global Variables | ✅ Yes | Add / edit / delete |
| Target Folder | ✅ Yes | A different folder can be picked |
| Data Source | ❌ No | Create a new query for a different MSSQL |
4. Update and Test
Make the changes in the editor. Test with the Run button.
T-SQL Update Tips
- You can increase the row count by changing the
TOP Nvalue. - Adding a
NOLOCKhint avoids read-lock issues. - Define a dynamic date range with
DATEADD().
5. Save
Click the Save button. Update the fields in the save panel. Save with Save.
6. Common Errors
| Error / Symptom | Possible Cause | Solution |
|---|---|---|
"you already have a query named '...'" |
The new name is used by another query | Enter a different name |
'LIMIT' is not a recognized T-SQL keyword |
LIMIT is invalid in T-SQL |
Use SELECT TOP N |
mssql: Invalid object name '...' |
Table not found or missing schema prefix | Add the schema, e.g. dbo.table |
"update failed: no rows were affected" |
The update was not saved | Refresh the page and try again |
| Cartography widget appears empty | A column name changed | Update the widget's data mapping |