-2
select customernumber into total 
from (select customernumber 
      from ccsowner.customer 
      where customernumber not in (select customernumber from MOBILEACCOUNTDETAILS))

Temporary table created through.

Create Table Total
(
    customernumber   Int
)
Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
Swathi
  • 1
  • 1

1 Answers1

1

Select Into will only work when the table doesn't exist. You can use the following SQL to insert data into existing table.

Try this -

Insert into Total 
 select customernumber 
    from ccsowner.customer 
    where customernumber not in (select customernumber from MOBILEACCOUNTDETAILS)

If you want to use the SELECT INTO, you could use the following SQL (It will create Total table on the fly and will give error if Total table is already existing):

;with cte_Cust As (
    Select customernumber 
      from ccsowner.customer 
      where customernumber not in (select customernumber from MOBILEACCOUNTDETAILS))


Select customernumber Into Total
   From cte_Cust
Nagahornbill
  • 121
  • 7
  • tried first one,but it's giving invalid number error. – Swathi Apr 07 '16 at 05:21
  • SQL Error: ORA-01722: invalid number 01722. 00000 - "invalid number" – Swathi Apr 07 '16 at 05:22
  • Check the datatype of CustomerNumber Column.. Seems like it is of datatype varchar. Please refer to http://stackoverflow.com/questions/12549029/sql-error-ora-01722-invalid-number for more explanation. – Nagahornbill Apr 07 '16 at 05:37