May 5, 2010 at 11:47 am
I know:
Linked server name, data source. How to know table name and retrieve data?
Thanks
May 5, 2010 at 11:56 am
exec sp_tables_ex MyLinkedServer will show you all the tables in the linked server that you can directly access; from there it's things like select * from MyLinkedServer...Tablename, and you might have to include the dbname or schema name, if it will not use default shortcuts.
MyLinkedServer.dbname.dbo.Tablename
Lowell
May 5, 2010 at 5:08 pm
1- Link the server
EXEC sp_addlinkedserver 'OracleSvr',
'Oracle 7.3',
'MSDAORA',
'ORCLDB'
2-SELECT
SELECT *
FROM OPENQUERY(OracleSvr, 'SELECT name, id FROM albert.titles')
3-UPDATE
UPDATE OPENQUERY (OracleSvr, 'SELECT name FROM albert.titles WHERE id = 101')
4-INSERT
INSERT OPENQUERY (OracleSvr, 'SELECT name FROM albert.titles')
VALUES ('NewTitle');
5-DELETE
DELETE OPENQUERY (OracleSvr, 'SELECT name FROM albert.titles WHERE name = ''NewTitle''')
if more information is needed, please let me know 😉
August 30, 2010 at 3:20 am
I have written an stored procedure that read some records from the remote table on the linked server.Actually whats the problem is When I execute the Stored Procedure ,the execution takes more than 30 minutes.Eventhough its taking such a long time its not returning any records.Just an message is there "Executing Query".Can anyone help me please?For more than a week am working on this ,why its not returning any record.
August 30, 2010 at 3:53 am
Why you have used OPENQUERY?is that the syntax to fetch the records from the linked server?
August 30, 2010 at 4:13 am
agnesloyola (8/30/2010)
I have written an stored procedure that read some records from the remote table on the linked server.Actually whats the problem is When I execute the Stored Procedure ,the execution takes more than 30 minutes.Eventhough its taking such a long time its not returning any records.Just an message is there "Executing Query".Can anyone help me please?For more than a week am working on this ,why its not returning any record.
There are several threads here on SC on Linked server performance;one thread which stated that openquery against a linked server was faster for a linked server vs a query on your server using 4 partnaming conventions;
for example, select * from LinkedServer.Databasename.dbo.MillionRowTable where something=somethingelse
vs
SELECT *
FROM OPENQUERY(LinkedServer, 'select * from MillionRowTable where something=somethingelse');
the reason: the first query gets the million rows locally into temp, then does the filtering, where the openquery does the work on the linkedserver, and returns just the results.
similarly, if you are joining a local table to a linked table to get results, it can take forever, because the MillionRowTable on the linked server gets copied over the wire to temp db, THEN the join to your local table is performed.
You'll have to look at the specific data you are trying to get form the linked server and limit it BEFORE you join to it to prevent that from happening.
Lowell
August 30, 2010 at 6:28 am
Thank you so much Lowell.Now its working fime after using OPENQUERY.Thanks a lot 🙂
August 30, 2010 at 6:34 am
agnesloyola (8/30/2010)
Thank you so much Lowell.Now its working fime after using OPENQUERY.Thanks a lot 🙂
glad i could help and thanks for the feedback!
that link server behavior's a good concept to keep in your mental toolbox!
Lowell
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply