SELECT INTO SQL SERVER AND SELECT INTO DB2

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
SQL SELECT INTO statement on mainframe differs from the way SELECT INTO SQL SERVER statement works. 
 
The SELECT INTO on mainframe is used in a COBOL DB2 program, to store the contents of a table into host variables
 
Following example shows how SELECT INTO works in a cobol program
 
EXEC SQL                                                
    SELECT *                                            
    INTO  :TABLE-NAME                                    
    FROM   TABLE_NAME                                 
    WHERE  FIELD_NAME  = :TABLE-NAME.FIELD-NAME    
END-EXEC.                                               
 

; ; ; ;

Here TABLE-NAME is the host variable copybook (the cobol declaration in the DCLGEN of the table TABLE_NAME)
 
TABLE_NAME is the name of the table
FIELD_NAME is the name of the field in the table
 
FIELD-NAME is host variable in DCLGEN TABLE-NAME
 
Note:- The SELECT INTO statement in a SQL server is used to take backups of tables.