SQL Command - Can't find server 'XXXXX'


I tried to write a sql command but face the error.

Error in advanced query SQL1: Could not find server' XXXXXX' in sys.servers.

Verify that the correct server name....

Could someone help it. Thanks a lot. 

Hi Howard,

Are you explicitly specifying a server, or is that database the default OutSystems database?

I use for default outsystems database. 

And everything else works fine? Like publishing, Aggregates etc.?

Yes, only when i do test command will face the error. 

Can you show the query you are trying to run? It seems that there is an error in the way you write your query.

The command as below

SELECT max({StockRequisitionHeader}.[SerialNumber]) from {StockRequisitionHeader}.[SerialNumber]
where {StockRequisitionHeader}.[SerialNumber] is not null

Hi Howard.

The problem is in your query:
from {StockRequisitionHeader}.[SerialNumber]

Just remove [SerialNumber] here.

OutSystems converts your original query to something like that:
In that case SQL server thinks that [DB_NAME] is a server name, that's why you get Could not find server error.

Hi Howard Hua

Vasily is right,  In From Clause you should use only the table name. Just Remove the .[SerialNumber] it will work.