Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to write a SQL query on Linked Server

Author  Topic 

prabhu_mm
Starting Member

6 Posts

Posted - 2011-07-20 : 08:53:32
Hi ...How to write a SQL query on Linked Server with Where condition

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-20 : 08:56:26
just like normal query
ie.

SELECT <columns>
FROM LinkedServer.DB.dbo.Table
WHERE <condition>


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

prabhu_mm
Starting Member

6 Posts

Posted - 2011-07-20 : 08:59:23
Thnx , But its keep on running..can u explain ..wat's the exact problm on that .

The below sample syntax has been tried

select columnname from linkeservername.DB name.dbo.table_name where Coumnname ='Datas'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-20 : 09:05:07
not any problem in query. it might be that linked server connection itself is slow. Can you check how long it takes to execute the query directly in the other server?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

prabhu_mm
Starting Member

6 Posts

Posted - 2011-07-21 : 01:26:04
Directly from server it wil only a fwe seconds ...but this keep on runnning running...i forced to cancel the qry to stop.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-21 : 02:13:57
can you try recreating linked server and then doing it. also whats the amount of data its retrieving?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

prabhu_mm
Starting Member

6 Posts

Posted - 2011-07-21 : 02:37:48
Ya i did , The retrive amount is only one row . Still i am facing the same problem...its keep on running
Go to Top of Page
   

- Advertisement -