Your temp table will not be accessible as sp_executesql runs your SQL in a different session then the one you create the temp table in. You would need to make it global ##Myatran. Also enable distributed transaction, RPC and RPC out on the linked server. when you insert from a local table into a table on a linked server, that is a distributed transaction.