OPENQUERY

Executes the specified pass-through query on the specified linked server.This server is an OLE DB data source. OPENQUERY can be referenced in the FROM clause of a query as if it were a table name. OPENQUERY can also be referenced as the target table of an INSERT, UPDATE, or DELETE statement. This is subject to the capabilities of the OLE DB provider. Although the query may return multiple result sets, OPENQUERY returns only the first one.
For Eg:
SELECT TOP 1* FROM OPENQUERY(TAW,'SELECT Column1,Column2
FROM DatabaseName.dbo.TableName')
Before running this query linked server has to becreated in the source server.Here 'TAW' is linkedserver name.
And most important thing is if we want to execute the stored procedure which is in other server we need to use OPENQUERY compulsorily.

Comments

Popular posts from this blog

System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out

Pre login Handshake or Connection Timeout Period

Transparent Data Encryption(TDE) with Master Key and Certificate in SQL Server