|
|
Archives of the TeradataForum
Message Posted: Thu, 08 Nov 2012 @ 15:04:20 GMT
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
| |