Solved

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

Posted on 2011-03-08
7
222 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 74

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 74

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

747 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

13 Experts available now in Live!

Get 1:1 Help Now