Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 22, 2012 06:33 AM by eralper
Nov 21, 2012 07:31 PM|LINK
I have a sql query that returns some values and I need to use those values as inputs to another SQL select statement.
The first sql query runs on DB1 that exists on server1. I want my web page to run the sqlquery1 and take the results of the query.
For example my sql query returns some values as
1 2 3 4 Then i need to use those values as inputs to another sql DB that exist on different server. And the final result displayed in my webpage.
What would be the easiest/effective way to do this. Imagine the queries are running on views and very limited access. No relations to DBservers either.
Nov 22, 2012 01:02 AM|LINK
You can have a Stored proc to do this, and inside that, you can capture the variable from 1st query like
declare @var1 nvarchar(80)
and further use such variable for other query.
Nov 22, 2012 01:11 AM|LINK
I think the most effective way would be to set up a linked server on one of the servers.
Nov 22, 2012 06:33 AM|LINK
To execute SQL query on an other server as Dan offered a
linked server is must
Within .NET code or in T-SQL procedure code, you can read values into parameters
Then you can query second server data over a linked server connection.