Results 1 to 2 of 2

Thread: Query a Query

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    53

    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!

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    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.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width