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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 sql statement between 2 servers

Author  Topic 

miri
Starting Member

9 Posts

Posted - 2007-12-19 : 02:10:33
Hi Everyone,

I try to write a sql statement ,who checks data between 2 servers .
one is sql2000 and the other is mssql2005.

How do I write the join command ?


Thanks!

miri

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-12-19 : 02:54:48
Do any one of these servers is added as a linked server on the other?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-19 : 03:10:14
or read about OPENDATASOURCE in sql server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

miri
Starting Member

9 Posts

Posted - 2007-12-19 : 03:28:23
yes,

the servers are linked .

Thank you.

miri
Go to Top of Page

Hariarul
Posting Yak Master

160 Posts

Posted - 2007-12-19 : 03:49:56
Try the below syntax..

SELECT A.Col1, B.Col1
FROM [SRVR1].[DB].[USR].[TABLE1] A ,
[SRVR2].[DB].[USR].[TABLE1] B
WHERE <Condition>
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-12-19 : 04:07:00
quote:
Originally posted by Hariarul

Try the below syntax..

SELECT A.Col1, B.Col1
FROM [SRVR1].[DB].[USR].[TABLE1] A ,
[SRVR2].[DB].[USR].[TABLE1] B
WHERE <Condition>



Never use Non-ANSI Join syntax.

Use ANSI syntax as below:

SELECT A.Col1, B.Col1 
FROM [SRVR1].[DB].[USR].[TABLE1] A JOIN
[SRVR2].[DB].[USR].[TABLE1] B
ON A.COL1 = B.COL1
WHERE <Condition>



Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2007-12-19 : 15:28:03
...just be aware that there are some performance issues in doing joins across linked servers. The DTC (distributed transactions coordinator) has to start up and this can cause some delays. You should also be aware that your query will be volnurable to all sorts of connectivity/network problems also...

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page
   

- Advertisement -