| Author |
Topic |
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-04-24 : 03:49:36
|
| i would like to know which of the following in table1 who has bought the code ABC.but i get this error:Invalid object name table1SELECT *FROM openquery( [testing] ,'select A.ID,FirstName,LastNamefrom (select * from table1)Ainner join (select ID from table2 with (nolock) where code in (''ABC'') )B on A.ID = B.ID') |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-24 : 21:42:05
|
| do you've table table1 present in server referred by testing?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-04-24 : 21:58:12
|
| I'm accessing using table1 db.Then I use the openquery which is testing to select the inner join on table2 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-24 : 22:24:20
|
| is table1 a db?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-04-24 : 22:32:45
|
| table1 is a table |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-24 : 22:40:57
|
| then what do you mean byI'm accessing using table1 db.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-04-24 : 22:53:32
|
| Oh I connect to the DB which can straight run select * from table1 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-25 : 00:34:58
|
| so table2 is in [testing] ?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-04-25 : 02:21:41
|
| Yes that is correct |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-25 : 14:39:33
|
then shouldnt it be this?select A.ID,FirstName,LastNamefrom table1 Ainner join(select * from openquery( [testing] ,'select ID from table2 with (nolock)where code in (''ABC'')'))Bon A.ID = B.ID------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|