Solved

What's the syntax for querying a linked server in sql 2005 sp3?

Posted on 2011-03-08
7
226 Views
Last Modified: 2012-05-11
I have setup a linked server to a mysql successfully.  But I need to know what's the
syntax like select, update...  Thanks.
0
Comment
Question by:lapucca
7 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35075993
IIRC, it should be:

    select * from [server name].[database name].[database owner].[table name]
0
 

Author Comment

by:lapucca
ID: 35076036
[server name] is the linked server name?  how do I find out what's the database owner name?  Would that be my mysql remote user id?
0
 
LVL 15

Accepted Solution

by:
derekkromm earned 400 total points
ID: 35076041
http://msdn.microsoft.com/en-us/library/ms188427(v=sql.90).aspx

select * from openquery(<yourlinkedservername>, 'select * from <yourtables>')
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 35076672
Correction to kaufmed:

select * from [server name].[database name].[schema name].[table name]


[schema name] not [database owner]
ie. dbo
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35076849
@BrandonGalderisi

Thanks. It's been years since I've actually done it    = )
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 100 total points
ID: 35082862
in mysql, there is no "database" name in that 4-part-name syntax.
what mysql names as databases, are translated into schemas.

however, as I only had problems with the 4-part-name syntax for mysql, I exclusively used the openquery method.
0
 

Author Closing Comment

by:lapucca
ID: 35086803
Thanks.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Server 208R2 not recognizing DBF file in linked Server 11 65
sql help 5 54
Help with SQL joins 9 54
How to use TOP 1 in a T-SQL sub-query? 14 48
Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question