XSolvo
Current user:   guest    Change     Preferences 
   List directory   History   Similar   Print version 
XSolvo 
   About XSolvo 
Articles 
html2xml 
tradufix 
TVProgramGrabber 
download 
Philosophy 
gallery 

Articles > LOCALSERVER

 
rw-rw-r--   stga   wheel

LOCALSERVER

A simple way to create a linked server to the current, local server.

sp_addlinkedserver    
    @server='LOCALSERVER', @srvproduct='',
    @provider='SQLOLEDB', @datasrc=@@SERVERNAME
INSERT     TableName
SELECT   DISTINCT *
FROM      OPENDATASOURCE(
         'SQLOLEDB',
         'Data Source=serverip,1433;User ID=sa;Password=****'
         ).DB.dbo.TABLE

If you want to access a remote server you must add a remote server login.

sp_addlinkedsrvlogin @rmtsrvname='servername' 
    , @useself ='false'
    , @locallogin = null
    , @rmtuser ='sa'
    , @rmtpassword =  'password'


Reference LOCALSERVER
http://www.xsolvo.com/Articles/LOCALSERVER


Prev. OPENQUERY   Reading, processing XML data in SQL Server Next