select into

select into requires column level permissions, including decrypt, on the source table.

Syntax

Encrypt columns on the new table using this syntax:

select [all|distinct] column_list
           into target_table 
           [(colname encrypt [with [database.[owner].]keyname] 
           [,colname encrypt
           [with [database.[owner].]keyname]])] 
       from tabname | viewname

NoteYou cannot reference a column in the partition_clause that is specified for encryption in the target table.

Example

Encrypting creditcard column in the bigspenders table.

select creditcard, custid, sum(amount) into        #bigspenders
       (creditcard encrypt with           cust.database.new_cc_key)
       from daily_xacts group by creditcard
       having sum(amount) > $5000