Re: Temp Table / Stored Procedure Question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Colin Angus Mackay (colin.angus.mackay_at_gmail.com)
Date: 12/15/04


Date: Wed, 15 Dec 2004 01:17:59 +0000

You create a temp table like any other except that the table name is
prefixed with a hash (#) character. Note that at the end of the stored
procedure the table will be dropped automatically.

If in your stored procedures you have a SELECT.... to return data out
then in your calling stored procedure all you need is:

INSERT #MyTempTable1
EXEC MyStoredProcedure @param1 = ''.... (or what ever you need)

Then you can perform a join as normal on the temp tables.

Does this help?

Joe Williams wrote:
> I am following up on some earlier posts I had:
>
> I have a procedure that calls two other stored procedures. I would like the
> values from the two stored procedures to be stored into a temp table and
> then as teh final step in my stored procedure, to join these two temp tables
> together and do a SELECT * to get all the data out.
>
> What is the process for declaring a temp table, then executing the stored
> procedure so that the data is stored into this newly created temp table?
>
> Thanks
>
> Joe
>
>

-- 
  - Developer Services Provider: http://wdevs.com
    For Blogs, FTP, Mail, Forums, Members Product Areas
  - My Blog: http://blogs.wdevs.com/ColinAngusMackay


Relevant Pages

  • Re: ms sql # temp table - invalid object name in data source
    ... A string of countys is passed into the procedure and turned into a temp ... reports, Delphi reports, etc. ... Now I'm trying to create a data source in a vb.net project. ... How is this handled as using # temp tables in MS SQL stored procedures is ...
    (microsoft.public.dotnet.framework.adonet)
  • ms sql # temp table - invalid object name in data source
    ... I have a MS SQL stored procedure that uses # temp tables in the following ... A string of countys is passed into the procedure and turned into a temp ... reports, Delphi reports, etc. ... find the list of stored procedures and check off the one ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: ms sql # temp table - invalid object name in data source
    ... This has to be a common problem with some ... A string of countys is passed into the procedure and turned into a temp ... reports, Delphi reports, etc. ... How is this handled as using # temp tables in MS SQL stored procedures is ...
    (microsoft.public.dotnet.framework.adonet)
  • ms sql # temp table - invalid object name in data source
    ... I have a MS SQL stored procedure that uses # temp tables in the following ... insert into #counties ...... ... A string of countys is passed into the procedure and turned into a temp ... find the list of stored procedures and check off the one ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Invalid object name #TempTable from SqlCommand (C#)
    ... that is any body using the stored procedures that manipulate the ... temp table will modify what you get out of the table... ... >> I'm having an issue accessing a temporary table in our SQL database and ... > see the statement execute through SQL Profiler. ...
    (microsoft.public.dotnet.framework.adonet)