Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Surrogate keys

Status
Not open for further replies.

peac3

Technical User
Jan 17, 2009
226
AU
Hi all,

I have table CLNT table in TERADATA as per below

Code:
CREATE TABLE [dbo].[CLNT](
	[CLNT_I]  NOT NULL,
	[FRST_NAME] [varchar](100) NULL,
	[LAST_NAME] [varchar](100) NULL,
	[UPDT_S] [date] NULL, 

) WITH PRIMARY KEY (CLNT_I) 

CLNT_I is meant to be surrogate key and as you know the identity column in Teradata is not always increment by 1.
And I would like to insert the CLNT table from temp table as per below code in SQL

Code:
MERGE INTO dbo.CLNT  AS target
USING dbo.temp AS source
    ON target.FRST_NAME = source.NAME    
	and target.UPDT_S = source.DATE_D    
WHEN MATCHED THEN 
    UPDATE SET target.UPDT_S = source.DATE_D
WHEN NOT MATCHED BY TARGET THEN
    INSERT (FRST_NAME, UPDT_S)
    VALUES (source.name, source.Date_D);

How would i do this simple command in teradata?
Thank you guys,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top