hi , Currently by using BTEQ and Teradata SQL assitant I am able to insert records into a table.
But I want to update records in a table. I have more than 2000 records in a table and i have 200 records in a file
both contain a same Primary key column and if there is no match found i want to insert a new row in a table.
so, its a UPDATE else INSERT scenario for mutliple records from a file to database table.
the syntax you're looking for is a MERGE INTO, please check the manuals.
There's also an old UPDATE ELSE INSERT syntax, but MERGE is more flexible.
based on your description i thought you already know how to import using SQLA/BTEQ.
Assuming your data is in a readable delimited format:
In SQLA set the delimiter to the correct char (in tools - options - export/import) and use question marks as you showed in your query.
And in BTEQ
.import vartext 'your delimited char' file = yourfile.txt;
USING a (varchar(xx))), b (varchar(xx)), c (varchar(xx))
Thanks, Dieter. I think I got the solution.
for this I have created the temporary table and imported data from a file
then by using this temporary table I am updating the actual table using MERGE INTO
Step 3: then imported data from a file. (created few sample records in a file)
INSERT INTO abc (cust_ky, fname,lname) VALUES (?,?,?)
Step 4: Updated my actual table using MERGE INTO