I have two database in different servers and i need to access one db object in another db. for ex, server1 (db1) and server2(db2(tableA,tableB) )
I will be writing a stored procedure in in db1 and i wanted to access the TableA's data of db2. i am aware of using the linked server. but i am, looking for alternate for linked server because i need to pass credentials at runtime to connect the server and access the objects.
Create Procedure Test(@server varchar(50),@username varchar(20), @pwd varchar(20))
select * from server2.db2.tableA;
the alternate i found is OpenQuery. not sure how should i accomplish using openquery and am not sure about the drawback of using this. please suggest me the best way to achieve this and if possible show me some sample.
Thanks in advance