473,473 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Temp Table on Linked Server

Trying to do this all day and googling for answers but found none, hope
someone can help. Thanks in advance.

select * into
OPENROWSET('SQLOLEDB','SERVER';'uid';'pwd',##test)
from LocalTable

Reason: I am joining local tables with linked server tables using the
format "LinkedServer.database.owner.object" to execute a query, it
takes forever to execute since the tables joined on the remote servers
have more than 50Mil records. I read somewhere that sql server needs to
copy the tables locally to the temp db and does the join there, hence I
was hoping to dump the data of the local database into a temp table on
the remote server and then do a join with OPENQUERY, which will execute
the query on the linked server and return the results.

Oct 7 '05 #1
8 12477
If the table is smaller on the local server then why not create a sp on the
remote one that joins these two tables and call the sp remotely?

--
Andrew J. Kelly SQL MVP
"Ootyguy" <np*****@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Trying to do this all day and googling for answers but found none, hope
someone can help. Thanks in advance.

select * into
OPENROWSET('SQLOLEDB','SERVER';'uid';'pwd',##test)
from LocalTable

Reason: I am joining local tables with linked server tables using the
format "LinkedServer.database.owner.object" to execute a query, it
takes forever to execute since the tables joined on the remote servers
have more than 50Mil records. I read somewhere that sql server needs to
copy the tables locally to the temp db and does the join there, hence I
was hoping to dump the data of the local database into a temp table on
the remote server and then do a join with OPENQUERY, which will execute
the query on the linked server and return the results.

Oct 7 '05 #2

Ootyguy napisal(a):
Trying to do this all day and googling for answers but found none, hope
someone can help. Thanks in advance.

select * into
OPENROWSET('SQLOLEDB','SERVER';'uid';'pwd',##test)
from LocalTable

Reason: I am joining local tables with linked server tables using the
format "LinkedServer.database.owner.object" to execute a query, it
takes forever to execute since the tables joined on the remote servers
have more than 50Mil records. I read somewhere that sql server needs to
copy the tables locally to the temp db and does the join there, hence I
was hoping to dump the data of the local database into a temp table on
the remote server and then do a join with OPENQUERY, which will execute
the query on the linked server and return the results.

Using OPENROWSET for big tabels is not good idea, so you have right
trying copy this table.
To copy this tabel you can use for example DTS. It will take you couple
minutes and you'll have what you want.

Oct 7 '05 #3
Andrew thank you for your idea. But the problem that I can't do this is
because, I have to join with more than 15 remote servers (in different
states, all having the same database) and I do not have permission or
control over them, all I have is the datareader role. Also in this case
as new states (databases) are added I will have to ask the dba of the
other state to create this sp for me which they may not agree.

Oct 8 '05 #4
Roan, thanks. I will try this when I get back to work on Monday.

Oct 8 '05 #5
Ootyguy (np*****@hotmail.com) writes:
Trying to do this all day and googling for answers but found none, hope
someone can help. Thanks in advance.

select * into
OPENROWSET('SQLOLEDB','SERVER';'uid';'pwd',##test)
from LocalTable

Reason: I am joining local tables with linked server tables using the
format "LinkedServer.database.owner.object" to execute a query, it
takes forever to execute since the tables joined on the remote servers
have more than 50Mil records. I read somewhere that sql server needs to
copy the tables locally to the temp db and does the join there, hence I
was hoping to dump the data of the local database into a temp table on
the remote server and then do a join with OPENQUERY, which will execute
the query on the linked server and return the results.


It may copy the entire table over the wire - but not by necssity.

What you try above is a dead end. What you could consider is to
optimize by hand, so to speak. If you know that you only will retrieve
a handful of those remote rows, then get those rows into a local table,
and use OPENQUERY, to be sure that it is a pass-through query.

Having 15 tables from 15 servers in the same query sounds like a nightmare
to me. Maybe you should consider replication to get the data into one
spot.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Oct 9 '05 #6
Let me clarify that I am not joining 15 tables against 15 remote
servers in one query, it is more like 6 linked tables and 2 local
tables against each database that is linked and this same query is
repeated against all the remote linked servers to gather data, create a
text file and ftp the file to a different location.

Since this is a job, it doesn't matter if it takes upto 45mins or an
hour, the problem is it works ok when the tables joined on the linked
servers are small, as more databases are added and the tables are large
it takes forever to execute.

Oct 10 '05 #7
I am not sure if I can use DTS because my current logic generates
dynamic sql for each remote server (around 15 servers, which will grow,
and information -uid;pwd;server; is stored in a table), the existing
DTS calls a stored procedure that generates this dynamic sql, executes
against each server, dumps the data in a temp table and then uses bcp
to generate a file, the DTS continues and ftp's the data to a different
location.

Oct 10 '05 #8
Ootyguy (np*****@hotmail.com) writes:
Let me clarify that I am not joining 15 tables against 15 remote
servers in one query, it is more like 6 linked tables and 2 local
tables against each database that is linked and this same query is
repeated against all the remote linked servers to gather data, create a
text file and ftp the file to a different location.

Since this is a job, it doesn't matter if it takes upto 45mins or an
hour, the problem is it works ok when the tables joined on the linked
servers are small, as more databases are added and the tables are large
it takes forever to execute.


If you join the six remote tables alone, how much data you get? Could
you run that query through OPENQUERY? Or would that still be too much
data to bring over?

Hm, in your OPENQUERY you could actually join to your local tables, that
is:

SELECT * FROM
OPENQUERY(REMOTE, 'SELECT ...
FROM localtable ..
JOIN YOURSERVER.db.dbo.tbl ')

Of course, you need to convince the other DBAs to set up linked servers
to your servers. But if they are not willing to co-operate, you should
probably not pull this data at all. Or you should talk with a manager.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Oct 10 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Per | last post by:
Why cant I use the same temptable name i a stored procedure after i have droped it? I use the Pubs database for the test case. CREATE PROCEDURE spFulltUttrekk AS SELECT * INTO #temp FROM...
1
by: Lauren Quantrell | last post by:
I have read the newsgroups and see this is a common issue but I saw no resolution for it: I have an Access2K frotn end and SQL Server 2K backend. In access, I create a temp table using code in a...
4
by: Neil Ginsberg | last post by:
I have ODBC linked tables to a SQL 7 database in an A2K database. The linked tables do not have the password stored in them, so the first time the user accesses them, they need to enter the SQL...
7
by: John Baker | last post by:
Hi: I would like to know how to create a temp DB to store the data in a table while I do something else with the table. Specifically, how do I create the temp remove the temp I want to be...
1
by: deko | last post by:
DoCmd.CopyObject copies data, but I only need structure. I'm trying to clone several tables in my Access 2003 mdb. The goal is to link to a series of Excel spreadsheets and then run various...
4
by: Wayne Wengert | last post by:
I am trying to create a VB.NET Windows application to move some data from a local Access DB table to a table in a SQL Server. The approach I am trying is to open an OLEDB connection to the local...
16
by: pukivruki | last post by:
hi, I wish to create a temporary table who's name is dynamic based on the argument. ALTER PROCEDURE . @PID1 VARCHAR(50), @PID2 VARCHAR(50), @TICKET VARCHAR(20)
2
by: Burbletrack | last post by:
Hi All, Hope someone can help me... Im trying to highlight the advantages of using table variables as apposed to temp tables within single scope. My manager seems to believe that table...
1
by: imani_technology_spam | last post by:
Right now, a client of mine has a T-SQL statement that does the following: 1) Create a temp table. 2) Populate temp table with data from one table using an INSERT statement. 3) Populate temp...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.