OPENROWSET ( 'provider_name'
, { 'datasource' ; 'user_id' ; 'password'
| 'provider_string' }
, { [ catalog. ] [ schema. ] object
| 'query' } )
provider_name is a character string that represents the friendly name of the OLE DB provider as specified in the registry. It has no default value.
datasource is a string constant that corresponds to a particular OLE DB data source.
userid is a string constant that is the username passed to the specified OLE DB provider.
password is a provider-specific connection string that is passed in as the DBPROP_INIT_PROVIDERSTRING property to initialize the OLE DB provider.
catalog is a name of the catalog or database in which the specified object resides.
schema is a name of the schema or object owner for the specified object.
object is a object name that uniquely identifies the object to manipulate.
query is a string constant sent to and executed by the provider.
Examples of OPENROWSET Function :
Example 1 : Use of OPENROWSET function in select clause
SELECT ContactName, CompanyName, ContactTitle
FROM OPENROWSET('MSDASQL',
'DRIVER={SQL Server};SERVER=seattle1;UID=manager;PWD=MyPass',
Northwind.dbo.Customers)
Above example returns Customers contactname, companyname and contacttitle by using the OLE DB Provider for ODBC and the SQL Server ODBC driver.