I have two sql database at different PC.how can link b/w
database and database tables.

Answer Posted / meenakshi

we can link database If both the DBs are on same Server and
the current user have access permission on both database
then you can use the following query..

Select SomeColumns From CurrentDBName..TableName
Select SomeColumns From OtherDBName..TableName

If the databases are on different Server then you have to
use the Linked Server..

EXEC sp_addlinkedserver @server = 'SERVER', @provider
= 'SQLOLEDB.1', @srvproduct = '', @provstr
= 'Privider=SQLOLEDB.1;Data Source=TargetServer;Initial
Catalog=Database'

go
Exec sp_addlinkedsrvlogin @rmtsrvname = 'SERVER', @useself
= true, @locallogin = null, @rmtuser = 'Userid',
@rmtpassword = 'Password'


On your SP you can use..

Select * From OpenQuery(MyRemoteServer, 'Select * From
Sysobjects')

--OR

Select * From MyRemoteServer.DatabaseName.dbo.Sysobjects

Is This Answer Correct ?    9 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why phpmyadmin is used for mysql?

497


What is a procedure example?

491


What is the difference between mysql_connect and mysqli_connect?

471


What is the use of pdo?

505


What is the insert?

486






Which mysql function is used to concatenate string?

768


How to escape special characters in sql statements?

523


What is database clustering in mysql?

473


What is the difference between timestamp and datetime in mysql?

541


How to dump a table from a database.

530


What is mysqlcommand?

473


What is difference between pdo and mysqli?

461


What are features of mysql?

469


Consider a scenario where you have to send an email to a client from the sql database. How do you think you can achieve this task?

509


What is mysql protocol?

454