1

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?

1 Answer 1

3

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 ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.