Click here to Skip to main content
15,903,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,

Please help me out, my requirement is create procedure that procedure join two tables in server 1 and move it to server table how to solve this one and

not using ssis and any import and export data

Thanks

ram
Posted

you should look at Linked Servers[^]
 
Share this answer
 
Comments
ramesh4128 25-Jul-12 3:16am    
how to create linked server in sql stored procedure can you please give the example
barneyman 25-Jul-12 3:35am    
Example AND documentation - accessible from the link I gave you

I'd suggest you read about it rather than just copying someone else by rote - you might learn something that helps you solve that, or other problems
You can use linked servers. Check below code

--Create Link to the Patron Server
@server = 'SERVER1',
@srvproduct = 'sqlserver',
@provider = 'SQLOLEDB',
@datasrc = '12.228.0.0' -- Server IP Address

--Create Login Credentitals to The Patron Server
EXEC Master.dbo.SP_ADDLINKEDSRVLOGIN 'SERVER1', 'false', null, 'sa', 'sa'

--Create RPC to Server
EXEC Master.dbo.sp_serveroption @server='SERVER1', @optname='rpc', @optvalue='true'
EXEC Master.dbo.sp_serveroption @server='SERVER1', @optname='rpc out', @optvalue='true'


EXEC SERVER1.<your databasename="">.dbo.<your procedure="" written="">
EXEC SERVER1.TempDB1.dbo.usp_GetDate



--Delete the Server link and Login Credentials
EXEC Master.dbo.sp_dropserver 'SERVER1', 'droplogins'
 
Share this answer
 
Comments
ramesh4128 25-Jul-12 3:21am    
example here

server 1 :

source 1 table

source 2 table

join the both table and load it into

server 2:

destination table
kishorekke 25-Jul-12 3:59am    
first connect to your server2 then write a procedure in ur server2 like below

@server = 'SERVER1',
@srvproduct = 'sqlserver',
@provider = 'SQLOLEDB',
@datasrc = '12.228.0.0' -- Server IP Address

--Create Login Credentitals to The Patron Server
EXEC Master.dbo.SP_ADDLINKEDSRVLOGIN 'SERVER1', 'false', null, 'sa', 'sa'

--Create RPC to Server
EXEC Master.dbo.sp_serveroption @server='SERVER1', @optname='rpc', @optvalue='true'
EXEC Master.dbo.sp_serveroption @server='SERVER1', @optname='rpc out', @optvalue='true'

-- Your query
SELECT * FROM SERVER1.TempDB1.dbo.Source1 S1 INNER JOIN SERVER1.TempDB1.dbo.Source2 S2 ON S1.ID=S2.ID


--Delete the Server link and Login Credentials
EXEC Master.dbo.sp_dropserver 'SERVER1', 'droplogins'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900