@Rabbit
Thanks for the reply. I like most your second method, and try to use it. However, it seems there is a little problem.
Here is my test result using SQL Server 2012. Instead of using two servers, I run the query on one server, and with different user accounts. I set up two user accounts (UA and UB) on the same SQL server "localhost". UA account has full access to AdventureWorks2012, and UB account has no access to AdventureWorks2012. I logon as admin and did two steps. First I did a reconfigure, and it was sucessful. Second, I tried to SELECT. If I use admin account, the select is successful, but it has no practical meaning because admin already has access to AdventureWorks2012. If I logon UB and tried to SELECT, I got an error:
-------------------------------------------------
sp_configure 'show advanced options', 1
reconfigure
GO
sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure
GO
-------------------------------------------------
SELECT * FROM OPENDATASOURCE
('SQLOLEDB', 'Data Source = localhost; User ID = UA; Password = UA123 ' )
.[AdventureWorks2012]
.[HumanResources]
.[Department]
-------------------------------------------------
The error message is "Msg 7416, Level 16, State 2, Line 1
Access to the remote server is denied because no login-mapping exists." Any idea?
--CUQ