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

Adding an index to a SQL table

I am using SQL Server 2008 R2. I am creating a table using Select.. Into... From where the From is actually 2 joined tables. Will the resultant table have the indexes of the original tables?
DeveloperM
  • 1,129
  • 7
  • 17
  • 30
0
votes
1 answer

sql appending data from other table to current table with conditions

I have 2 tables, PRODUCT and VENDOR. The attributes for each are as follows: PRODUCT: product_id, product_name, price, vendor_id VENDOR: vendor_id, vendor_name, vendor_phone, vendor_address I want vendor_name to show in PRODUCT where vendor_id in…
user2540029
  • 11
  • 1
  • 3
0
votes
3 answers

Select into Table from Table2 where column in (Subquery)

SELECT .... ColumnNames ... INTO [FOUND_DUPLICATES] FROM [FIND_DUPLICATES] AS FD WHERE FD.[Contract No] IN (SELECT [Contract No], [Vehicle Identity number (VIN)], COUNT(*) AS Anzahl FROM FIND_DUPLICATES GROUP…
Denis1893
  • 65
  • 2
  • 10
0
votes
2 answers

Error 1064 in a procedure

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= (se lect ifnull(max(manufactureId+1),1) from tbl_Manufacturer ) ; create…
Nisar
  • 5,708
  • 17
  • 68
  • 83
0
votes
3 answers

PostgreSQL: Select several queries into same table

Good day, I have a table with some records that should be deleted. I would like to keep track of the deleted records and place such records in a new table. I would like to do the following: SELECT * INTO TEMP FROM TABLE WHERE criteria < 1; And…
0
votes
2 answers

Copy the Result Set Into another table

I just want to copy the result set of this query into another table using Java: select basescore, count(*) from log group by basescore ;;;;;suppose________INTO log2 FROM log I have tried a lot but it gives me errors can anybody help please.…
user2496503
  • 907
  • 5
  • 13
  • 21
0
votes
1 answer

SELECT INTO that returns more then 1 row - ORA-01422

I have 3 tables: products (prod_id, prod_name, prod_sale_price), order_details (order_id, prod_id, prod_quantity) and orders (order_id, order_date, cust_id, emp, id). Basically Im trying to create a function that gets the total order cost when…
Michael
  • 199
  • 1
  • 9
0
votes
3 answers

SQL Server 2000: select into case when in order by clause

I am trying to select rows into a temporary table with a CASE statement in the ORDER BY clause but records are not being sorted on insert. Declare @orderby varchar(10) , @direction varchar(10) set @orderby = 'col1' set @direction = 'desc' select…
user1430949
  • 849
  • 1
  • 6
  • 10
-1
votes
1 answer

Stored procedure to create tables for each employee code using INTO clause

I am trying to create tables which are specific to employee ID. I can run simple select statement in a stored procedure. But I want to create tables using INTO clause which I can then export into CSV files. When I write INTO clause, I get an…
Bunny
  • 43
  • 1
  • 10
-1
votes
1 answer

PostgreSQL save table columns results into variables

I have this function: DECLARE _first_name text; _last_name text; BEGIN SELECT emp.first_name INTO _first_name, emp.last_name INTO _last_name, FROM employee emp LIMIT 1 END; (I simplified the function to eliminate the information…
john2994
  • 393
  • 1
  • 3
  • 15
-1
votes
2 answers

Oracle SQL: "missing keyword" when using SELECT INTO with a recursive CTE

Inside a stored procedure, I am trying to set value of a declared varchar(100) variable 'my_path' based on a virtual dataset created via a WITH and recursive CTE statement. First I tried "SELECT INTO", but got "missing keyword" error. I can…
Matin
  • 117
  • 5
  • 15
-1
votes
2 answers

ora-01422 error in SELECT INTO statements

I have one row in my Company_Person_all view named by 'YENER UZUN' in EMPLOYEE_NAME column (I already want only one result). When I send parameter to this function (fname, instead of using 'YENER UZUN') I encounter ORA-01422:exact fetch returns more…
-1
votes
1 answer

Cannot get select into to work

I have a database squid with a table configs. I am trying to get the configs table into a different database [testsquid] on the same host. Here is what I've tried: select * into testsquid.configs from squid.configs; I tried first without creating…
slicks1
  • 349
  • 1
  • 13
-1
votes
1 answer

Oracle declare select into update statement does not work

I had an issue where due to database charset special characters would get weird codes assigned to them, then by getting select ascii(substr(declinereasondesc, 30,1)) from DECLINEREASON t where declinereasonid = 7; I got code (49827) for £ in db…
Matas Vaitkevicius
  • 58,075
  • 31
  • 238
  • 265
-1
votes
2 answers

mysql insert into or select into - copy column from tbl1 into tbl2

So I have 2 MySQL tables in the same database with the following columns (all of which are NOT NULL): tbl1: (url, urlkey, domain, created, 8 more columns..) tbl2: (url, urlkey, canonical) These 2 tables both have 100,000 rows right now - and they…
Nathan Fraenkel
  • 3,422
  • 4
  • 18
  • 21
1 2 3
10
11