Solved

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

Posted on 2011-03-08
7
223 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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 142

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

929 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now