|
|
|
Supreme Being
      
участник
Last Login: 01.05.2003 9:57
Сообщ.: 218,
Visits: 2 399
|
|
| Есть SQL server 6.5 (мой) и SQL server 7 (удаленный). Нужно законнектиться к нему и выполнить select (параметры connectiona известны, можно даже создать ODBC data source). Как это сделать? Объясните чайнику.
|
|
|
|
|
Forum Guru
      
участник
Last Login: 17.04.2003 15:55
Сообщ.: 69,
Visits: 760
|
|
используй sp_addlinkedsrv sp_addlinkedsrvlogin
по моему так, вчера делал доступ MSSQL->Oracle, так уже имена забыл :-), а в SQL Book Online залезать не охота.
|
|
|
|
|
Supreme Being
      
участник
Last Login: 01.05.2003 9:57
Сообщ.: 218,
Visits: 2 399
|
|
| Проблема в том, что sp_addlinkedserver, sp_addlinkedsrvlogin, а также openrowset и openquery не доступны в 6.5. Можно сделать sp_addserver, но я не очень понимаю, что делать дальше.
|
|
|
|
|
Forum Guru
      
участник
Last Login: 17.04.2003 15:55
Сообщ.: 69,
Visits: 760
|
|
sp_addserver [@server =] 'server' [,[@local =] 'local'] [,[@duplicate_ok =] 'duplicate_OK']
Arguments [@server =] 'server' Is the name of the server. Server names must be unique and follow the rules for Microsoft Windows NT® computer names, although spaces are not allowed. server is sysname, with no default. [@local =] 'LOCAL' Specifies whether the server that is being added is a local or remote server. @local is varchar(10), with a default of NULL. Specifying @local as LOCAL defines @server as the name of the local server and causes the @@SERVERNAME function to return server. (The Setup program sets this variable to the computer name during installation. It is recommended that the name not be changed. By default, the computer name is the way users connect to SQL Server without requiring additional configuration.) The local definition takes effect only after the server is shut down and restarted. Only one local server can be defined in each server. [@duplicate_ok =] 'duplicate_OK' Specifies whether or not a duplicate server name is allowed. @duplicate_OK is varchar(13), with a default of NULL. @duplicate_OK can only have the value duplicate_OK or NULL. If duplicate_OK is specified and the server name that is being added already exists, then no error is raised. @local must be specified if named parameters are not used. Return Code Values 0 (success) or 1 (failure) ---------------------------------------------------------------------- sp_addremotelogin [@remoteserver =] 'remoteserver' [,[@loginame =] 'login'] [,[@remotename =] 'remote_name']
Arguments [@remoteserver =] 'remoteserver' Is the name of the remote server that the remote login applies to. remoteserver is sysname, with no default. If only remoteserver is given, all users on remoteserver are mapped to existing logins of the same name on the local server. The server must be known to the local server (added using sp_addserver). When users on remoteserver connect to the local server running Microsoft® SQL Server™ to execute a remote stored procedure, they connect as the local login that matches their own login on remoteserver. remoteserver is the server that initiates the remote procedure call. [@loginame =] 'login' Is the login ID of the user on the local SQL Server. login is sysname, with a default of NULL. login must already exist on the local SQL Server. If login is specified, all users on remoteserver are mapped to that specific local login. When users on remoteserver connect to the local SQL Server to execute a remote stored procedure, they connect as login. [@remotename =] 'remote_name' Is the login ID of the user on the remote server. remote_name is sysname, with a default of NULL. remote_name must exist on remoteserver. If remote_name is specified, the specific user remote_name is mapped to login on the local server. When remote_name on remoteserver connects to the local SQL Server to execute a remote stored procedure, it connects as login. The login ID of remote_name can be different from the login ID on the remote server, login. Return Code Values 0 (success) or 1 (failure)
|
|
|
|
|
Supreme Being
      
участник
Last Login: 01.05.2003 9:57
Сообщ.: 218,
Visits: 2 399
|
|
|
|
|
|
Forum Guru
      
участник
Last Login: 17.04.2003 15:55
Сообщ.: 69,
Visits: 760
|
|
Executing a Distributed Query When executing a distributed query against a linked server, include a fully qualified, four-part table name for each data source to query. This four-part name should be in the form linked_server_name.catalog.schema.object_name. For example, to run a “SELECT * FROM employees” query against a SQL Server data file and an Oracle data file, the distributed query would look similar to the following:
SELECT emp.EmloyeeID, ord.OrderID, ord.Discount
FROM SQLServer1.Northwind.dbo.Employees AS emp,
OracleSvr.Catalog1.SchemaX.Orders AS ord
WHERE ord.EmployeeID = emp.EmployeeID
AND ord.Discount > 0
|
|
|
|
|
Supreme Being
      
участник
Last Login: 01.05.2003 9:57
Сообщ.: 218,
Visits: 2 399
|
|
| distributed query в 6.5 тоже нет (можешь убедиться, посмотрев new features в books online по 7.0). :(
|
|
|
|
|
Forum Guru
      
участник
Last Login: 17.04.2003 15:55
Сообщ.: 69,
Visits: 760
|
|
Ну ты же можешь использовать полные имена в секции FROM:
[[[server.][database].][owner_name].]object_name
|
|
|
| | |