the error is pretty straight forward; it could not find the table in the database. maybe when you abstracted it out, you hid the issue.
do you Really have a database named ? ANd a Table named [T]?
on my server, I KNOW i have a database named SandBox, and another database named 'PERFECT1200'
I also KNOW the tables i'm using exist.
this worked without errors:
like you said, I'm logged in as a sysadmin for testing this:
EXEC sp_addlinkedserver
@server=N'SELF',
@srvproduct=N' ',
@provider=N'SQLNCLI',
@datasrc=@@SERVERNAME
SELECT * FROM SELF.PERFECT1200.dbo.GMACT
SELECT * FROM SELF.SANDBOX.dbo.AllMeasures
Now, if i log in as the user [ClarkKent], that user MUST BE A USER IN BOTH DATABASES.
if he's a user in one database, but not a user in the linked server database, that's an expected security error.
i bet that's where your error is.
you either need to allow the linked server to use other credentials , or make the user a user in both databases.
now in real life, you never use SA.
what i usually do is create multiple users without login, and use that user for permissions for reading data on the lined server:
CREATE USER READ_ONLY WITHOUT LOGIN;
EXEC sp_addrolemember 'db_datareader','READ_ONLY'
EXEC sp_addrolemember 'db_datawriter','LIMITED_USER'
CREATE USER LIMITED_USER WITHOUT LOGIN;
EXEC sp_addrolemember 'db_datareader','LIMITED_USER'
EXEC sp_addrolemember 'db_datawriter','LIMITED_USER'
Lowell