All Forums Database
digo 9 posts Joined 06/09
06 Jul 2009
Create temporary table

I need to create a temporary table using as source a portion of another table from my TeraData DataBase.The temporary table must have the same definition of the source table.I know what the syntaxe would be like in SQLServer:"Select top 10 * into TempTable from SourceTable"But when I try this in TeraData I get the error message:Syntaxe error: INTO clause is not allowed.Can anybody help me to solve this problem or find another way to do the trick?Thanks in advance.Rodrigo.

CarlosAL 512 posts Joined 04/08
06 Jul 2009

Try INSERT INTO TempTable SELECT TOP 10 * FROM SourceTable if TempTable is created beforehand.Try CREATE TABLE AS... syntax if not.HTHCheers.Carlos.

digo 9 posts Joined 06/09
06 Jul 2009

Never mind answering, guys, I have already found out how to do what I need.Just to register here the solution I came up with (and hopefully help anyone who eventualy stumbles in this issue):"CREATE TABLE tempTable AS (select top 10 * FROM sourceTable) WITH data;Note: The version 12 of TeraData does not support this construction for sourceTables containing Identity Columns =/ I hope they fix that for newer versions...Regards.Rodrigo.

digo 9 posts Joined 06/09
06 Jul 2009

Hehehe that is just what I did, Carlos!Thanks, anyway. ;)Rodrigo.

i5commuter 10 posts Joined 01/12
29 Feb 2012

For others who are used to using temp tables at the session level only , I have added the missing qualifier.

CREATE Volatile TABLE tempTable AS (select top 10 * FROM sourceTable) WITH data;

 

You must sign in to leave a comment.