是否可以在链接服务器上创建临时表? [英] Is it possible to create a temp table on a linked server?

查看:111
本文介绍了是否可以在链接服务器上创建临时表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对远程链接服务器进行一些相当复杂的查询,因此能够将一些信息存储在临时表中,然后对它进行联接(对所有远程数据)将很有用.在本地创建临时表并通过导线与它们临时连接非常慢.

I'm doing some fairly complex queries against a remote linked server, and it would be useful to be able to store some information in temp tables and then perform joins against it - all with the remote data. Creating the temp tables locally and joining against them over the wire is prohibitively slow.

是否可以强制在远程服务器上创建临时表?假设我没有足够的权限来创建自己的真实(永久)表.

Is it possible to force the temp table to be created on the remote server? Assume I don't have sufficient privileges to create my own real (permanent) tables.

推荐答案

不可能在链接的远程服务器上直接创建临时表.实际上,您不能对链接服务器使用任何DDL.

It's not possible to directly create temporary tables on a linked remote server. In fact you can't use any DDL against a linked server.

有关使用链接服务器的准则和限制的更多信息,请参见:

For more info on the guidelines and limitations of using linked servers see:

使用分布式查询的指南(SQL 2008联机丛书)

一个变通方法(并且不在我的脑海中,并且只有在您拥有远程服务器权限的情况下才可以解决),您可以:

One work around (and off the top of my head, and this would only work if you had permissions on the remote server) you could:

  • 远程服务器上有一个存储过程,该存储过程将创建一个持久表,其名称基于IN参数
  • 远程存储过程将运行查询,然后将结果插入此表
  • 然后您可以对该表进行本地查询,对所需的任何本地表执行任何联接
  • 完成后,调用远程服务器上的另一个存储过程以删除远程表

不理想,但是可以解决.

Not ideal, but a possible work around.

这篇关于是否可以在链接服务器上创建临时表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆