Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
heze
Posting Yak Master
192 Posts |
Posted - 2006-10-26 : 12:51:18
|
| hi I wonder if its possible to create a global temp table in the tempdb database of a remote server, something like this:select * into [someRemoteServer].tempdb.dbo.##globalTempTablefrom myTableI tried to do this but was unsuccessful ---------thank you |
|
|
heze
Posting Yak Master
192 Posts |
Posted - 2006-10-26 : 13:37:35
|
| actually I triedselect * into [someRemoteServer].##globalTempTablefrom myTableand it works, the problem is that the .##globalTempTable is stored in my local serverwhen I wury the sysobjects in the remote server, the table is not there |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
heze
Posting Yak Master
192 Posts |
Posted - 2006-10-26 : 13:48:34
|
| ok X,I want to join a local table A with a remote table BI have full admin rights in the local server but only read permissions in the remotethe remote table B is huge so if I doselect * from tableA a left join TableB bon a.id=b.idthe query takes forever, however I dont need the entire table B, so I was thinking on reducing the table B in its own server to only the records that I will need to join,and then join it and then just bring back to the local server only what I need,I am able to doselect *into ##globalfrom TableBin the query analyzer when I open it connected to the remote server, so I dont know if it is a permission thingregarding the error message, there is no error message its only that the ##tableB appears to be stored in my local server rather than in the remote one (at least that is what I assume since i can see it in the local.tempdb..sysobjects but not in the remote.tempdb..sysobjects) if I am correct in my assumption, then I am left with the same preoblem of importing all the rows to my local server and the query takes forever.Oh by the way, the where clause is not very useful because local Table A is a dated (temporal) table (snapshots) whereas the table B is transactional and has the current state so I either have to do a join or an where id in (some id list)thanks |
 |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-10-26 : 16:09:47
|
| There's a better way - just use the OPENQUERY function (see Books Online) to pass the query to the remote server that you would have used to create the temporary table on the remote server and then SQL Server will only get those rows from the remote server.Note that it is however wrong to assume that SQL Server is bringing the whole table across anyway, when you use a remote table in a query SQL Server will do a very good job of bringing over only the data that is needed for the query. But - if you want fine control over exactly what is brought over use OPENQUERY. |
 |
|
|
|
|
|
|
|