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
0 answers

db2 dynamic sql with select into clause in anonymous block

I am working on a DB2 SQL code. I need to get the count of records from a list of tables. The table details will be fetched from a cursor with select. To get the count of records I have been trying with a SELECT INTO statement. Since the table…
Krish
  • 1
  • 1
0
votes
3 answers

PL/SQl sqldeveloper want to output multiple rows in plsql

I have a procedure and anonymous block, where I enter in two dates and it searches the tickets table for the tickets that have been resolved during those two dates and outputs em. But I can't seem to figure out how to output multiple rows in…
itadaki
  • 5
  • 4
0
votes
2 answers

How to join tables easily Microsoft SQL Server?

I have two separate tables used for categories. One is Categories(ID, Title, Description), and the other is SubCategories(ID, UpperID, Title, Description) I want to insert the records from categories to SubCategories with upperID=0. I've looked at…
HasanG
  • 12,734
  • 29
  • 100
  • 154
0
votes
4 answers

Insert Into Select stored procedure not working inserting NULL

My first time creating a stored procedure here please go easy on me. I was trying to SELECT my data from Table 1 (EmpTBL), then INSERT it into Table 2 (EventTBL) I think the culprit is this line right here: @Ename varchar(250) = NULL, @Edate…
0
votes
3 answers

SELECT values of an INSERT INTO statement

I need to select a few columns from a table1. I need to insert only one of these columns as well as some arbitrary hard coded data and insert it into table2 while also getting the original select statement back. Basically I would like to get the…
CodingIsSwell
  • 125
  • 2
  • 11
0
votes
2 answers

SELECT * INTO #testtable query takes quite a bit of time?

select TableA.Sys_ID, TableA.State_Code, TableA.Zip_Code, TableA.Birth_Date, TableA.Gender, TableA.Source_code, TableB.Sys_ID into #testtable from DM.TableA inner join DM.TableB on TableA.Sys_ID = TableB.Sys_ID; TableA has about…
blacksite
  • 12,086
  • 10
  • 64
  • 109
0
votes
1 answer

ORA-00934: group function is not allowed here

I have written a stored procedure that I was expecting to add two count values into a collection, with the below code: PROCEDURE generate(code_in in VARCHAR2 , value_1 out NUMBER , value_2 out NUMBER) is BEGIN …
Radu Gheorghiu
  • 20,049
  • 16
  • 72
  • 107
0
votes
2 answers

sas: proc sql select into with more than one output

I have following dataset data height; input name $ var $ value; datalines; John test1 175 Peter test1 180 Chris test1 140 John test2 178 Peter test2 182 Chris test2 148 ; run; I would like to make mean value of 2 tests for each students I…
useR
  • 3,062
  • 10
  • 51
  • 66
0
votes
2 answers

Average grade of student temporary table in SQL Server

I have a database with the following tables: Students_T (SNo, SDedc, SAddress) Courses_T (CNo, CDesc) CoursesRegister_T (CRNo, CR_CNo, CR_SNo, CRGrade) I need to represent the following data: For each student show: Student desc, Course desc,…
divelner
  • 244
  • 1
  • 2
  • 10
0
votes
3 answers

Select into VS Import and export wizard in sql server

In sql server, From my desktop I connected to the server. And I want to move a data from a database to another. I have used both select into and import wizard. But import wizard seems to be slow. Why? Is there any methodology changes for…
Vignesh M
  • 168
  • 3
  • 14
0
votes
3 answers

Oracle case when exists using same variable as insert into

I came across a piece of T-SQL I was trying to convert into Oracle. It looks like this: SET @local variable= CASE when exists (select field from table where value=0) then 0 when exists (select same field from same table where…
Andrew Martin
  • 5,619
  • 10
  • 54
  • 92
0
votes
3 answers

Oracle, how to open cursor and select one column of many into a variable

I have a Oracle stored procedure returning a reference cursor. I want to open the cursor before i return it to check a count and throw an exception if need be, but im having trouble with syntax and how im supposed to do this. V_ASN_COUNT …
SomeRandomDeveloper
  • 489
  • 2
  • 13
  • 33
0
votes
1 answer

Oracle select into variable, ERROR ORA-00947 not enough values

I want to grab a count of distinct ASN_NO's from my query to later check in my stored procedure if i find more than one and throw an error. Instead of trying to open the cursor(which i was also failing at doing properly), i thought maybe i could do…
SomeRandomDeveloper
  • 489
  • 2
  • 13
  • 33
0
votes
2 answers

Using a synonym in a make-table query ("select into")

I always thought a synonym in T-SQL was just a convenient abbreviation. Yet when I do the following ... create synonym BACKUP_TABLE for T_SHORT_NAMES_BACKUP go select * into BACKUP_TABLE from T_SHORT_NAMES ... I get the error that there is already…
Dom
  • 71
  • 1
  • 2
  • 6
0
votes
1 answer

MySql OUT Parameter in Create Procedure not compiling

I'm attempting to write a MySQL Stored Procedure but I can't seem to get it to compile with multiple OUT parameters after selecting from the table. And I couldn't find any specific examples for what I'm attempting to do. The compiler error states,…
Rion
  • 545
  • 1
  • 3
  • 10