Questions tagged [select-into]

The SQL command SELECT INTO statement copies data from one table into a new table. See https://www.w3schools.com/sql/sql_select_into.asp

SELECT INTO is available in various database systems so please tag the type of database being used as well.

158 questions
0
votes
1 answer

Select Into - Redshift

Does select * into table query work in Redshift? I get the following error when I try it: JDBC Driver]com.amazon.dsi.dataengine.impl.DSISimpleRowCountResult cannot be cast to com.amazon.dsi.dataengine.interfaces.IResultSet [SQL State=HY000] 1…
0
votes
1 answer

MSACCESS - How to add a primary key using a query make table

I have a query make table with this SQL: SELECT DISTINCT tblStore.Position, tblStore.Branch, tblStore.Location, tblStore.Operator INTO tblAllPositions FROM tblStore WHERE (((tblStore.Position) Is Not Null)) ORDER BY tblStore.Position,…
Alex
  • 113
  • 1
  • 14
0
votes
1 answer

SAS Select Into Dynamic Naming

I am trying to use SAS proc sql select into for 8 different scenarios. %MACRO Loop(); proc sql; %do i=1 %to 8; select total_value into :Sol_&i. separated by ',' from Master.adjusted_hours where…
ldan
  • 41
  • 1
  • 6
0
votes
1 answer

Dynamize range of SAS PROC SQL SELECT INTO macro creation

I want to put multiple observations into an own macro variable. I would do this by using select into :obs1 - :obs4, however, as count of observations can differ, i would like to dynamize the range and my code looks like this: proc sql; create…
Niels
  • 141
  • 8
0
votes
0 answers

Using MySQL 8 I’m finding wrong output results while calling a stored procedure

Calling a stored procedure using input and output parameters returns different results compared to running the stored procedure code directly as a query. I cannot grasp why MySQL 8 would process the stored procedure like this. Would appreciate it of…
0
votes
0 answers

How can I alter a temporary table with 36 million rows to add a new column?

I am working with a temporary table in Netezza that contains the columns id, gender, start_date, and end_date. I want to add a new column to this table that contains a default date of 2019-01-01 for all rows. The table to which I want to add this…
Kellan Baker
  • 375
  • 3
  • 11
0
votes
1 answer

store all the values of a column returned by a select query in a variable - PostgreSQL

I have a table which maintains records of the transactions carried out within the enterprise. Now I am writing a function that returns the transaction IDs that were found in the table. Following is the code of the function : CREATE OR REPLACE…
Karan Parikh
  • 311
  • 3
  • 18
0
votes
2 answers

Changing a datatype in a table without reaching the transaction log limits

I have a huge table with about 100 million rows in SQL Server and want to change the datatype from varchar to nvarchar like this: ALTER TABLE my_table ALTER COLUMN comment NVARCHAR(250); The problem is that my transaction log grows until the…
Christian
  • 4,902
  • 4
  • 24
  • 42
0
votes
1 answer

Key Differences Between Views and Created Tables Using SELECT INTO?

I understand that a view is only a saved SQL query that can be considered as a virtual table. However, it seems to me that there is not much difference between creating a new table using the SELECT INTO statement and creating a view. What are some…
Danny Brown
  • 17
  • 1
  • 6
0
votes
1 answer

mysql workbench select and select into issue

not sure why this is baffling me.. strange that have the things I see for how to do this are showing as errors in the workbench.. so I want to select first into var and select out next.. then use the var to update.. but it never works.. so I found…
kevin_kss
  • 33
  • 4
0
votes
2 answers

Create table from results of >8000 char SQL Linked Server query

I'm trying to create a table on SQL Server based on the results of Oracle SQL >8k chars. Is this possible without openquery which has that 8k limitation. Here's what i'm trying to do but can't seem to get it to work: SELECT * INTO #TMP001 EXEC…
Dee Rinos
  • 15
  • 5
0
votes
0 answers

Insert into temp table with clustered index performance

I've tested two scenarios A and B. I was surprised that scenario A took 11 seconds and B took 16 seconds. A. 1) Create temp table 2) Create a clustered index on that temp table 3) Use INSERT INTO SELECT to Insert 2 million records into this temp…
neela
  • 77
  • 6
0
votes
1 answer

Select Into/Insert Into SQL Server query duplicates

Sorry for asking this question, but I am a beginner in SQL, my colleague at work build a view, which I need as datasource for a report, however since this view is based on several other views it takes like 45 minutes to execute the query. This is…
awaker
  • 3
  • 1
0
votes
1 answer

How long should an select into query take when selecting from a table with ~200 million rows in sql server 2005?

I have a table with 193,569,270 rows in a SQL Server 2005 database. The table houses activities that are performed by users of our website. The table is defined as: Name DataType ID int (identity) …
Wayne E. Pfeffer
  • 245
  • 1
  • 7
  • 15
0
votes
2 answers

T:SAS/ Proc SQL - select into: not in:

I currently have a proc contents datafile which looks like this: DATA CONTENTS; INPUT NAME $; DATALINES; VARA VARB VARC VARD VARE ; RUN; and I'm looking to turn this last of variables into a macro…
user5572129