473,390 Members | 878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

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 12472
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.