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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / anil

You can also use curl function for use defferent database

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More MySQL Interview Questions

If you specify the data type as DECIMAL (5,2), what?s the range of values that can go in this table?

2 Answers  


What is key in mysql?

0 Answers  


What is row locking in mysql?

0 Answers  


mysql> select * from store; +------+-------+-------+ | id | month | sales | +------+-------+-------+ | 1 | 1 | 100 | | 1 | 2 | 100 | | 1 | 3 | 200 | | 1 | 4 | 300 | | 1 | 5 | NULL | | 1 | 6 | 200 | | 1 | 7 | 800 | | 1 | 8 | 100 | | 1 | 9 | 240 | | 1 | 10 | 140 | | 1 | 11 | 400 | | 1 | 12 | 300 | | 2 | 1 | 300 | | 2 | 2 | 300 | | 2 | 3 | 300 | | 2 | 4 | 200 | | 2 | 5 | 200 | | 2 | 6 | 200 | | 2 | 7 | 100 | | 2 | 8 | 100 | | 2 | 9 | 300 | | 2 | 10 | 100 | | 2 | 11 | 150 | | 2 | 12 | 150 | +------+-------+-------+ this is my table. i need to display output like this. +------+----------+----------+----------+----------+ | id | quarter1 | quarter2 | quarter3 | quarter4 | +------+----------+----------+----------+----------+ | 1 | 400 | 500 | 1140 | 840 | | 2 | 900 | 600 | 500 | 400 | +------+----------+----------+----------+----------+ what single query i have to write for this. i tried this query and it displays like the below mysql> select id,sum(sales) as quarter1,(select sum(sales) from store where mont h>3 and month<7 ) as quarter2,(select sum(sales) from store where month>6 and mo nth<10)as quarter3 from store where month>0 and month<4 group by id; +------+----------+----------+----------+ | id | quarter1 | quarter2 | quarter3 | +------+----------+----------+----------+ | 1 | 400 | 1100 | 1640 | | 2 | 900 | 1100 | 1640 | +------+----------+----------+----------+ 2 rows in set (0.00 sec) tel me how to rectify it.

2 Answers  


write a command to view the content of the table

0 Answers  


Is mysql relational database?

0 Answers  


What is session variable in mysql?

0 Answers  


What is trigger in mysql with example?

0 Answers  


How is mysql database stored?

0 Answers  


How do I setup mysql?

0 Answers  


How do I delete a row in mysql?

0 Answers  


maximum database size of mysql database

2 Answers  


Categories