SQL Query Troubleshooting Tip

by | Feb 18, 2016 | SQL Server Reporting Services, Tips

Last updated on August 6th, 2022 at 03:55 pm

Before starting to write a SQL Server Reporting Services (SSRS) report, you need to create a SQL query that will be used within the report. I always recommend that you create your query within SQL Server Management Studio (SSMS). Microsoft Endpoint Configuration Manager (MEMCM / MECM / SCCM / ConfigMgr ) administrator, we are not always savvy with SQL Server queries. This article will help you with SQL Query Troubleshooting Tip.

SQL Query Troubleshooting Tip

How do you troubleshoot queries when you get an error?

When you use SSMS, it is fairly easy to troubleshoot query issues because SSMS will provide you with information about the error.

Take the following example. You’ll notice that SSMS tells me there is a syntax error and it is found on Line 5.

SQL Queries Troubleshooting Tip-Syntax Error

You might ask, “Which line is Line 5”? Notice that the red arrow in the screenshot below is pointing to my cursor. Now see that the black arrow is telling me that I’m on Line 2. Given this information, I know that a few more lines down will be the incorrect syntax.

SQL Queries Troubleshooting Tip-Line Information

Quickly looking at that line I can tell that my query has the wrong quotation marks within it. For example, styled quotes instead of regular quote marks. After I fix the quotation marks this query will work great. You will see this a lot when you cut and paste from a blog site. The stylized quote always seem to post on blogs / articles.

Once the query is good to go. I copy it to SQL Server Data Tools for Visual Studio 2013 (SSDT) / SQL Server Business Intelligence Development Studio (BIDS).

What other SQL Queries tips would you like to learn about, Drop me a line!

Finally, don’t forget that you can subscribe to my RRS feed to stay on top of the latest trips and tricks. Additionally, If you have any questions, please feel free to touch base @Garthmj.