Trying to do this all day and googling for answers but found none, hope
someone can help. Thanks in advance.
select * into
OPENROWSET('SQL OLEDB','SERVER' ;'uid';'pwd',## test)
from LocalTable
Reason: I am joining local tables with linked server tables using the
format "LinkedServer.d atabase.owner.o bject" 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. 8 12529
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*****@hotmai l.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com... Trying to do this all day and googling for answers but found none, hope someone can help. Thanks in advance.
select * into OPENROWSET('SQL OLEDB','SERVER' ;'uid';'pwd',## test) from LocalTable
Reason: I am joining local tables with linked server tables using the format "LinkedServer.d atabase.owner.o bject" 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.
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('SQL OLEDB','SERVER' ;'uid';'pwd',## test) from LocalTable
Reason: I am joining local tables with linked server tables using the format "LinkedServer.d atabase.owner.o bject" 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.
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.
Roan, thanks. I will try this when I get back to work on Monday.
Ootyguy (np*****@hotmai l.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('SQL OLEDB','SERVER' ;'uid';'pwd',## test) from LocalTable
Reason: I am joining local tables with linked server tables using the format "LinkedServer.d atabase.owner.o bject" 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****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
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.
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.
Ootyguy (np*****@hotmai l.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(REMOT E, 'SELECT ...
FROM localtable ..
JOIN YOURSERVER.db.d bo.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****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 Jobs
|
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 module:
strSQL = "CREATE TABLE #tempTableName ("TempID int NOT NULL IDENTITIY
(1,1) PRIMARY KEY, Field1 int...)
CurrentProject.Connection.Execute strSQL,,adCmdText
so far so good...
|
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 password.
I am developing a process that will automatically run at night which will
access those tables. I need to be able to give Access the password, as the
user currently does, so that the process can run without a password prompt
appearing....
|
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 certain that these are not linked or anything.
|
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 action queries
against the data in the linked tables (to massage and import it). Since I
can't run action queries against linked Excel tables, I need to create temp
tables that are clones of the required existing tables in the database then
append...
| |
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 Access DB and then add a Linked
Table pointing to the table on the SQL Server and then run an "Insert Into
(linked table)" query to add the new rows.
I am having a problem getting the syntax to add that linked table to my
local Access DB. When I...
|
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)
|
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 variables are not advantageous
because they reside in memory.
He also seems to believe that temp tables do not use memory...
|
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 table with data from another table using an INSERT
statement.
4) SELECT from temp table.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |