Query throug sql servers

  • Hi, does anyone knows how to make a query trough two sql servers without using a linked server?

    Thanks and regards, AC.

  • Try OPENDATASOURCE .'

    From Books Online

    Provides ad hoc connection information as part of a four-part object name without using a linked server name.

    Remarks

    The OPENDATASOURCE function can be used in the same Transact-SQL syntax locations as a linked server name. Thus, OPENDATASOURCE can be used as the first part of a four-part name that refers to a table or view name in a SELECT, INSERT, UPDATE, or DELETE statement, or to a remote stored procedure in an EXECUTE statement. When executing remote stored procedures, OPENDATASOURCE should refer to another SQL Server. OPENDATASOURCE does not accept variables for its arguments.

    Like the OPENROWSET function, OPENDATASOURCE should only reference OLE DB data sources accessed infrequently. Define a linked server for any data sources accessed more than a few times. Neither OPENDATASOURCE, nor OPENROWSET provide all the functionality of linked server definitions, such as security management and the ability to query catalog information. All connection information, including passwords, must be provided each time OPENDATASOURCE is called.

    Examples

    This example accesses data from a table on another instance of SQL Server.

    SELECT   *

    FROM     

    OPENDATASOURCE(        

          'SQLOLEDB',

          'Data Source=ServerName;User ID=MyUID;Password=MyPass'

          ).Northwind.dbo.Categories

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply