Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Validate data before inserting new data

iamRandy
8 - Asteroid

I have a SQL table that i'm trying to insert new data every day, but im concerned that a duplicate row may be inserted. Is there a way to validate if a data is existing before inserting new records. I'm thinking to use a date field or can you validate the entire row? thanks.

 

Duplicate.png

6 REPLIES 6
Felipe_Ribeir0
16 - Nebula

Hi @iamRandy 

 

Do these tables have a primary key?

 

1)I think that the best option would be to use the option Update; Insert if new.

 

Felipe_Ribeir0_0-1668118641691.png

 

 Another 2 options if the previous one is not possible, these usually works but i think it is not like a good practice 😅.

 

2)You can compare input and compare both tables (first one would be pick the max date from some column of the previous day table, compare with the current day table and filter just dates after that.)

 

Felipe_Ribeir0_1-1668118967738.png

3)second one, join both tables by the proper columns and let just the new data go to the output

 

Felipe_Ribeir0_2-1668119196455.png

 

 

iamRandy
8 - Asteroid

My table is historical YTD .. let me try your suggestion

iamRandy
8 - Asteroid

No there's no primary key.

Felipe_Ribeir0
16 - Nebula

If you have historical data with some date column that can be used to separate old data from new date, the second option will work

 

Felipe_Ribeir0_0-1668125575348.png

 

Felipe_Ribeir0
16 - Nebula

Hi @iamRandy 

 

It worked?

iamRandy
8 - Asteroid

I created a primary key field (RecordID) and i am able to insert new rows

Labels
Top Solution Authors