Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 08 Nov 2012 @ 15:04:20 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: How to generate Surrogate Key using CSUM?
 
From:   Bernard, Vincent L

If you first insert into a stage table, this will work:

     INSERT INTO TARGET_TABLE
        ( EDW_ID,
          TEL_NUM,
          FNAME,
          LNAME,
          ADDRESS,
          CITY,
          STATE
        )

     SELECT
        RANK(TEL_NUM ASC)+MAX_EDW_ID,  --AUTO GENERATED EDW_ID
        TEL_NUM,
        FNAME,
        LNAME,
        ADDRESS,
        CITY,
        STATE

     FROM
        STAGE_TABLE  AS STAGE
            , ( SELECT
                   COALESCE(MAX(EDW_ID), 0)
                FROM
                   TARGET_TABLE
                       ) AS TARGET ( MAX_EDW_ID )
     ;

Vincent Bernard



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023