-1

I'm using a Postgresql database in Azure, but when I use the temporary table, an error occurs stating that it's not allowed.

The example code is:

select * into temptable from act_hi_taskinst

And error is:

SELECT ... INTO is not allowed here

enter image description here

I also tried as informed on the link https://www.postgresqltutorial.com/postgresql-select-into, but I still have the same error.

Does anyone have an idea of how to solve this? Thanks

Henrique Mauri
  • 718
  • 6
  • 20

3 Answers3

1

If you are using Postgres, then the Postgres equivalent is CREATE TABLE AS:

create table temptable as
    select * 
    from act_hi_taskinst;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
0

SELECT INTO With SQL Azure SQL Azure requires that all tables have clustered indexes therefore SELECT INTO statements, which creates a table and does not support the creation of clustered indexes. If you plan to migrate to SQL Azure, you need to modify your code to use table creation instead of the SELECT INTO Statement. This goes for both temporary tables (where clustered indexes are not required) and permanent tables.

https://azure.microsoft.com/en-au/blog/select-into-with-sql-azure/

To work around this you need to create your destination table then call INSERT INTO. Here is an example:

CREATE TABLE #Destination (Id int NOT NULL, [Name] 
Lenroy Yeung
  • 291
  • 3
  • 8
0

Here - INTO Concept Example

Insert into temptable
select *  from act_hi_taskinst;