SIGN UP MEMBER LOGIN:
   
ARTICLE

OPENDATASOURCE() Function use in SQL Server

Posted by Sapna Malik Articles | SQL Server September 07, 2010
In this article, We will see how to use Opendatasource() Function in SQL Server.
Reader Level:

HTML clipboard

In this article, We will see how to use Opendatasource() Function in SQL Server.

OPENDATASOURCE() Function:-The OPENDATASOURCE() Function is the part of Rowset() function. This function is the system function. The Opendatasource() Function is Provides ad hoc connection string information without a linked server name. This function is accesses data from a table on another instance of SQL Server.

Syntax:-

USE DatabaseName
GO
SELECT
* FROM OPENDATASOURCE ( Provider_Name, Init_String ).TableName
GO

Provider_Name:-The Provider_Name as a datatype. The Provider_Name is a name registered as the PROGID of the OLE DB provider used to access the data source.

Init_String :-The Init_String is a connection string of SQL Server.

 

Example:- In this example, We will see how to accesses data from a 'StudentRecord' on another instance of SQL Server.

USE Data
GO
SELECT
*
FROM OPENDATASOURCE('SQLOLEDB',
'Data Source=MCNDESKTOP10;User ID=sa;Password=wintellect' ).dbo.StudentRecord
GO

 

Login to add your contents and source code to this article
This Feature is Sponsored By
post comment
COMMENT USING
TRENDING UP