Toon posts:

SQL 2000 query over 2 verschillende databases/servers

Pagina: 1
Acties:
  • 53 views sinds 30-01-2008

Verwijderd

Topicstarter
op twee van onze Microsoft SQL servers (SP3) wil ik een query doen. op beide servers staat 1 database. Op beide databases is het klantnummer uniek en matchen dus met elkaar.

Maar hoe draai je in godsnaam zo'n query? ALS het al mogelijk is.

[edit]
Ja, een nieuw topic. omdat 1 of andere lolbroek als antwoord geeft:
Op F1 drukken in Query Analyzer.
en dan het topic sluit.

Alsof ik nog niet verder gekeken heb. Ik heb al heel wat afgegoogled, Microsoft.com/technet, Microsoft.com/kb, Expert-exchange.com etc. etc.

Dus sorry, maar ik ben het echt niet eens met de manier van sluiten van dit topic.

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 12-05 22:23

curry684

left part of the evil twins

Je topic is dicht en het is onterecht? Lees hier!

Maar voordat je me mailt moet je echt SQL Books Online nog eens doorlezen.

Professionele website nodig?


  • curry684
  • Registratie: Juni 2000
  • Laatst online: 12-05 22:23

curry684

left part of the evil twins

Working with Tables from Different Data Sources

You can create distributed, heterogeneous queries —queries from tables and table-structured objects outside the server to which you have created a data connection. SQL Server can access any data source that supports OLE DB. You can use tables and table-structured objects from these outside data sources as you would any tables available on the base server (if you have proper permissions to access to the outside data source).

Microsoft SQL Server can access outside data sources in two ways. The first is using a linked server, which is defined in the SQL Server database to point to the outside data source. A linked server makes the data source accessible using a naming convention similar to that of native SQL Server data objects. The second is to use a dynamic reference to the outside source using the OpenRowset( ) function, which allows you to connect to any accessible data source in your query, even if no linked server is defined for it.

Tables and table-structured objects from outside servers do not appear as part of the list of tables. Instead, to use them, you use syntax in the SQL pane of the Query Designer to refer to the linked server or to include the OpenRowset( ) function. However, when you refer to an outside data source in the SQL pane, the Query Designer adds a rectangle representing the table or table-structured object to the Diagram pane to represent the outside data source.

To refer to an outside data source using a linked server, use the following syntax to refer to the table: linkserver.catalog.schema.object
Where:
• linkserver represents the name on the local Microsoft SQL Server data source given to the linked server in OLE DB.
• catalog represents the name of the database containing the object.
• schema represents the owner of the object.
• object represents the table or view in the database.

The following is an example of an SQL statement that joins data from tables from the local database with a table on a server called "hrserver":

SQL:
1
2
3
SELECT e.id, e.lname, h.hiredate
FROM employee AS e INNER JOIN hrserver.hr.dbo.hiredata AS H
ON e.emp_id = h.emp_id
De rest mag je zelf opzoeken, dit is rechtstreekste C/P uit SQL online help :)

Professionele website nodig?


Dit topic is gesloten.