Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2007
    Location
    Orlando,FL
    Posts
    35

    Unanswered: Stored Proc in SQL Code

    Using SQL Server 2005. Writing SQL code but I need to use the reults from two different stored proc. How do you code a select statement using a stored proc. I know when using views you just use the view name in the From or join statemnt, but do you do the same with using a Stored proc. Thank you for your help. David

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    It's a real nightmare David. Sprocs are not really written for this. Depending on circumstances, you may be best rewriting these sprocs as table valued functions or amalgamting them into one (if you don't require code reuse). Otherwise you can insert the output into tables and join these:
    Code:
    INSERT INTO mySprocOutput EXEC MySproc

  3. #3
    Join Date
    Jul 2007
    Location
    Orlando,FL
    Posts
    35
    Thank, let me see if I can create some tables from the stored proc. David

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Note - you can't create the table as part of the insert like you can with SELECT... INTO. You need to create the table first.

  5. #5
    Join Date
    Nov 2006
    Location
    Quebec
    Posts
    172
    I recommend you to SELECT INTO ##temp_tbl

    Then SELECT * FROM ##temp_tbl JOIN ##...
    Less is more.
    How long is now?
    http://www.lesouterrain.com

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    I strongly recommend that you code this logic as a user-defined table function.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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