Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

temporaries tables 1

Status
Not open for further replies.

precimonito

Programmer
Jan 20, 2001
18
EC
Hi... i need a complex query.. so i need use temporaries tables, i don`t know why in sql server didn't work .. maybe i use the incorrect syntaxis...

this is the query:

with tblTemp as ( select .....)
select col1, col2 from tblTemp

but i got a syntaxis error... everyone can help me?
thanks :)
Precimonito
 
Hello Precimonito,

I don't recognize the use of WITH. Are you working with Microsoft SQL Server? My experience with temporary tables is that they are created and used in stored procedures like this.
Code:
CREATE TABLE #tblTemp as
  (col1 datatype, col2 datatype, . . .)
  .  .  .
select col1, col2 from #tblTemp
The # as the first character of the table name makes it a temporary table.

What is the error message?
 
Hi rac2 :)
i use "temporaries tables" when i work with db2 DB,
i don't sure if the name is correct in the sql server context... i mean like a buffers where i put the data and then uses it in another select... in this way i don´t need create explicity temporaries tables.

thanks
Precimonito
 
You don't need a temporary table. You can use a derive table.

SELECT A.col1, A.col2
FROM (select col1, col2 from OtherTable) as A


Andel
andel@barroga.net
 
Thanks a lot Andel... i change the syntaxis and it works !!! :)

Precimonito
 
There is a forum for DB2, it is number 178. search forums for db2.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top