Re: Creating temp table

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Gregory A. Larsen (greg.larsen_at_netzero.com)
Date: 05/20/04


Date: Thu, 20 May 2004 14:22:59 -0700

you might try something like this:

create procedure x as
create table #x (col1 int, col2 int)
insert into #x select col1, col2 from a
insert into #x select col1, col2 from b
insert into #x select col1, col2 from c
select * from #x
drop table #x

-- 
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Bret" <anonymous@discussions.microsoft.com> wrote in message
news:FC0C05A0-BBFF-48D3-ABCD-E46081BE0C3C@microsoft.com...
> Please, I want to create a stored procedure that does the following:
> *  Creates a temporary table
> *  Selects data from a table and appends to this temp table
> *  Selects data from a second table and appends to this temp table
> *  Selects data from a third table and appends to this temp table
>
> All 3 source tables have exact design and format.a
> thank you.
>


Relevant Pages

  • Re: Inserting multiple records into two tables...with a twist
    ... I assume that you have an IDENTITY column, ... reason would typically be a high rate of concurrent insertions.) ... INSERT tblB(id, col1, col2, ... ...
    (comp.databases.ms-sqlserver)
  • Dynamic PreparedStatements with Variable In Parameters
    ... AND col2=? ... AND col3=? ... I have to start coding tomorrow so I'm eager ...
    (comp.lang.java.programmer)
  • Re: Required property of Primary Key fields
    ... col1 INTEGER NOT NULL, ... PRIMARY KEY (col1, col2) ... it's a bit pointless because the INSERT will fail with a "primary key ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Strange effects of Cast
    ... Cast to tuncate strings. ... In the query below although I get the expected result in COL1 and COL2 ... COL3 and COL4 return only three characters. ...
    (comp.databases.oracle.misc)
  • RE: tough query (for me)
    ... query, I had to write VB code which used one query which obtained all of the ... would obtain data from both Col1 and Col2 into a recordset. ... Col1 and Col2 data to an array. ...
    (microsoft.public.access.queries)