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.
| Author |
Topic |
|
mflammia
Starting Member
44 Posts |
Posted - 2008-07-31 : 18:11:46
|
| Trying to write a query that will compare the contents of a Linked server table with a local one and return only the results of those that match. I have tried to gleam what I can below from this link http://weblogs.sqlteam.com/jeffs/archive/2004/11/10/2737.aspx but get the following error:Msg 156, Level 15, State 1, Line 9Incorrect syntax near the keyword 'FROM'.Msg 156, Level 15, State 1, Line 15Incorrect syntax near the keyword 'FROM'.SELECT MIN(TableName) as TableName, ID, COL1FROM( select * from openquery (TTDNY1,'Select ID, listingTitle from listings') as TableName, A.ID, A.COL1 FROM A UNION ALL Select ID, _name from realessex.dbo._DATA as TableName, A.ID, B.COL1 FROM B) tmpGROUP BY COL1HAVING COUNT(*) = 2Order by IDNot sure what is happening. Your help is greatfully received as usual. |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-07-31 : 23:24:57
|
| What are 'from a' and 'from b' for? |
 |
|
|
sunsanvin
Master Smack Fu Yak Hacker
1274 Posts |
Posted - 2008-08-01 : 03:09:43
|
| --you are not using linked server here. openquery considers any database as homogenioususe the table name before alias namesArnavEven you learn 1%, Learn it with 100% confidence. |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-08-02 : 14:44:30
|
| You can access linked server with openquery. |
 |
|
|
|
|
|
|
|