-
Query a Query
In the query builder in visual studio 2008 (visual basic) can you use an already created query in a new query,i.e.
in a new query called query2, use table1 and query1.
If not in the query builder, which would be very helpful, is there another way in StoredProcedures or code?
Thanks!
-
Re: Query a Query
I've never used Query Builder so I have no clue about that. Subqueries in stored procedures or code are fairly common, however.
Code:
SELECT * FROM [dbo].[Users] WHERE UserID IN (SELECT UserID FROM [dbo].[BannedUsers])
Stored procedures will return a value or record set but as far as I know, you can't use them as a subquery. I tried before but couldn't get it to work.
SQL Functions, however, can be used in a Subquery just like my example above.
Hope that helps.