select into

select into requires column-level permissions, including decrypt, on the source table. The following partial syntax for select into includes only clauses specific to encryption. See the Reference Manual for the complete syntax.

Syntax

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

Example

This example encrypts the creditcard column in the bigspenders table:

select creditcard, custid, sum(amount) into        #bigspenders
       (creditcard encrypt with           custdb.dbo.cc_key)
       from daily_xacts group by creditcard
       having sum(amount) > $5000

Usage