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
 openquery within openquery

Author  Topic 

umniza
Starting Member

19 Posts

Posted - 2010-07-07 : 15:27:46
Is it possible? Because there is no array in sql, I am trying to do something like

SET @SQL='
(select * from openquery
('+ @One +',''
select *
from state
where
(city in
(select city from openquery
('+ @Two +',''
select city
from state_smaller ''
)
)
)
with ur ''
) as A
) B '


*PS : just figured out how to keep formatting :)

umniza
Starting Member

19 Posts

Posted - 2010-07-07 : 15:37:45
formatting did not translate well...

I was trying to show that I open connection 'One' and within it I want to open connection 'Two', so I can use its results in the outer select of the 'One'. I am getting error messages like "incorrect syntax near select" or "near ') "

But I'm not even sure I can do openquery within openquery to begin with. If it's possible, could someone show me exact formatting with the apostrophes? Thank you!
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-07-07 : 18:08:30
Continue discussion here:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=146981

Locking this thread
Go to Top of Page
   

- Advertisement -