Welcome to the Alteryx Knowledge Base
Knowledge Base / Designer / SQL Server - SQL Editor Test Query Failed With "Error opening <query>: No Columns Returned."
SQL Server - SQL Editor Test Query Failed With "Error opening <query>: No Columns Returned."
Created/Edited -
Summary
Description
Error opening <query> : No Columns Returned
Issue
Environment
- Input Tool | SQL Editor | Test Query
- SQL Server DSN-Less or DSN
Cause
If the SQL Server DSN-Less connection string or DSN does not include a default database, the SQL Editor does not know which database to validate the query against.
Resolution
If you do not wish to include a default database in either the DSN-less connection string or the DSN, go to Solution A. If you want to set a default database, go to Solution B.
Solution A - Qualify the Table Call in the SQL With the Database Name and Schema That the Table Belongs Too
- Paste your query into the SQL Editor
- For all tables referenced in the query, qualify them with the database name and the schema to which the tables belong.
- For example, if you have "SELECT * FROM Department," you will change it to "SELECT AdventureWorks2017.HumanResources.Department.* FROM AdventureWorks2017.HumanResources.Department."
Solution B - Specify a Default Database in the DSN-Less Connection String or DSN
- If you are using a DSN-less connection string, make sure to include the DATABASE= parameter.
- For example, odbc:Driver={SQL Server Native Client 11.0};Server=ayx.extendthereach.com\sql;Database=AdventureWorks2017;Uid=testdummy;Pwd=__EncPwd1__;Trusted_Connection=yes
- If creating a DSN, check the box "Change the default database to" and enter the database name
Additional Information
Note: The “No Columns Returned” error is most commonly caused by a missing database context in the SQL connection. Defining a default database or fully qualifying table references will resolve the issue in most cases.
Was this article helpful?