Skip to main content

Questions tagged [select-into]

Questions about the SELECT INTO statement used to create a table from a SELECT statement (or store scalar results into variables in a procedural language). See also the tag [ctas].

Filter by
Sorted by
Tagged with
18 votes
2 answers
4k views

Disk space full during insert, what happens?

Today I discovered the harddrive which stores my databases was full. This has happened before, usually the cause is quite evident. Usually there is a bad query, which causes huge spills to tempdb ...
HoneyBadger's user avatar
3 votes
0 answers
82 views

Double registration when using select into

SQL Server 2019 CU15, Database Audit: When auditing a SELECT on a database, everything looks fine, but if I SELECT INTO a #myTempDB, I get double registration in the AUDIT LOG. I created a test ...
Torben iisager's user avatar
3 votes
0 answers
520 views

Time to generate execution plan for select into from a view takes significantly more time than select

I have a view, vw_example, that is quite complicated and has multiple joins across multiple databases. This view has been causing significant delays when used as part of other queries, and we've ...
Simon's user avatar
  • 131
1 vote
1 answer
59 views

Select into query, insert fails, but the table is created

I am using SQL Server 2016 and I tried to the following query. SELECT CONVERT(BIGINT, 'A') col1 INTO #tmp This query is obviously in error. Because it does not convert. However, the temporary table (...
Suseong Park's user avatar
1 vote
2 answers
2k views

How much storage space do indexes and keys take for an SQL Table?

I have a table which is predominantly filled with NULLS and takes up 10 GB which was shocking since probably 90 to 95% of the table is NULLS. I copied this table over to a new database on the same SQL ...
Sam's user avatar
  • 21
1 vote
1 answer
588 views

SQL Server: I need to estimate execution time of a SELECT .. INTO .. statement

To take backup of a big table (using SELECT .. INTO .. ) took me almost 4 hours in a machine with 4 CPUs and 16 GB of RAM. No external application/process were accessing the table during the operation....
RGO's user avatar
  • 423
1 vote
2 answers
2k views

Why am I getting the "Query has no destination for result" error?

I'm starting on PL/pgSQL, and have written this code to update and return a query, but it isn´t working. This is the SQL error: SQL Error [42601]: ERROR: query has no destination for result data Hint:...
Gozcab's user avatar
  • 11
1 vote
2 answers
14k views

How can I obtain the last inserted row with INSERT ... SELECT in PostgreSQL?

I'm trying to batch-copy data in a specific order from one table to another in PostgreSQL 12-beta2. The table is not using sequences, but contains an composite unique Primary Key (user_id, object_id). ...
gertvdijk's user avatar
  • 227
0 votes
2 answers
320 views

How to implement "SELECT INTO" in Oracle with PostgreSQL commands?

I have seen many explanations about SELECT INTO in the oracle clause. I found a difference in applying SELECT INTO in Oracle and other SQL databases. In Oracle, the SELECT INTO statement retrieves ...
devins10's user avatar
0 votes
1 answer
253 views

Create an empty table from an existing table keeping the default value constraint

I tried: Select * Into <DestinationTableName> From <SourceTableName> Where 1 = 2 but the default value constraint is not created. I have a smalldatetime column whose default value is ...
Rick's user avatar
  • 115
-1 votes
2 answers
1k views

How to speed up an insertion from a huge table with postgres?

I have 5 tables in my database with respectively a size of 70Gb, 500Mb, 400 Mb, 110Mb and 20 Mb. I want to create a new table that contains all columns of all tables, so I tried 2 queries, the first ...
Islacine's user avatar
-2 votes
1 answer
64 views

Select into statement

Is it possible to use "select into" statement when we are joining different tables which have 1 or more same column names? Eg: Table1 has column name as description and Table2 has column name as ...
Tharun Reddy's user avatar