Saturday, January 4, 2020

ad hoc distributed queries

EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO

USE [test]

SELECT *
INTO mytable1
FROM OPENDATASOURCE (
        'SQLNCLI'
        ,'Data Source=182.76.144.132;Initial Catalog=****;User ID=***;Password=****'
        ).BARRAGE.dbo.Jamrar
    /*  steps - 
            1-  [mydb1] means our opend connection database 
            2-  mytable1 means create copy table in mydb1 database where we want insert record
            3-  XXX.XX.XX.XXX - another server name.
            4-  mydb2 another server database.
            5-  write User id and Password of another server credential
            6-  mytable2 is another server table where u fetch record from it. */

No comments:

Post a Comment

Ad hoc queries

 select max(cast(convert(varchar, convert(datetime, [CR_DATE], 103), 101) as date))  from OPENDATASOURCE (        'SQLNCLI'         ...