Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Inserting to mssql - update if new?

Hamder83
11 - Bolide

Hi 

I have created a small table with these columns:
/****** Script for SelectTopNRows command from SSMS ******/
SELECT [ProductName]
,[ProductCode]
,[ProductCountry]
,[ProductType]
,[SubCarrierID]
,[SubCarrierName]
,[ProductStatus]
,[StartDate]
,[EndDate]
,[MultiColli]
,[AvailableOnAPI]
,[ShopProduct]
,[Direction]
,[id]
FROM [MasterData].[Products]



ID is PK and has identity 1.


If ProductCode exist then its an update on that row.
If it does not, then its new and should be inserted.

How do i define my output to that?


This keeps adding as new :\ 

 

Hamder83_0-1686123119941.png

 




3 REPLIES 3
geraldo
13 - Pulsar

@Hamder83 
Did you look at the mapping if everything is correct in the Append Field Map option?

If there is no other PK in the BD

 

and the pk and identity 1 field should not work

 

 

If you don't pass the ID Null to the  update it will insert and not update

nagakavyasri
12 - Quasar

There will be 'Key for Update' field when the option 'Update:Insert if new' selected to select the update column, try checking for this option

 

Screenshot 2023-06-07 120158.png

Hamder83
11 - Bolide

oh, I didnt have that option of using oledb. I changed it to odbc and it worked.

Thank you :-) 

 

 

Labels