SQL Server – Use Multiple Expressions in Select List

sql serversql-server-2008-r2t-sql

I am attempting to run this syntax

Select
[StoreName] = (Select *
              FROM OPENQUERY(192.168.5.812,'Select
                                    storename
                                    FROM stores') x
              WHERE x.storename = y.storename)
[StoreManager] = y.storemanager
FROM managerinfo y

But this gives me an error of

Msg 116, Level 16, State 1, Line 28
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

Is it possible to do this while using OPENQUERY? How can I achieve my desired result?

Best Answer

Try changing your * with just the column name. Although it means the same, now it should be clear to SQL Server:

SELECT
    [StoreName] = (SELECT storename
                     FROM OPENQUERY(192.168.5.812, 'SELECT storename
                                    FROM stores') x
                    WHERE x.storename = y.storename)
    [StoreManager] = y.storemanager
FROM 
    managerinfo y ;