Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

upsert Sql server table

hali11251
6 - Meteoroid

hi

I am trying to use Alteryx for data warehouse load. Anyone used this tool for loading data to dimension and fact tables? Insert is working fine but when i have to do update it failed. I like to do Upsert (update and insert) to the table. Any suggestions or comments.

 

Regards

Hali

5 REPLIES 5
fmvizcaino
17 - Castor
17 - Castor

Hi @hali11251 ,

 

In order to 'update, insert if new' to work, you must have a primary key in your database table.

Let me know if this is the case for you.

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Output-Data-Tool-update-insert-if-new/...

 

Best,

Fernando Vizcaino

hali11251
6 - Meteoroid

Thank you for your response. I do have primary key in my table. When we run the object then it insert the data into table first time. When you rerun the process, my expectation is that if data is already there then need to update, if needed ,otherwise just finished the task with no error. 

 

but i m getting this error:

 

 

" Output Data (14) DataWrap2ODBC::SendBatch: [Microsoft][SQL Server Native Client 11.0][SQL Server]Violation of UNIQUE KEY constraint 'UQ_Organization_OrganizationID'. Cannot insert duplicate key in object 'dbo.DimClient'. The duplicate key value is (1).[Microsoft][SQL Server Native Client 11.0][SQL Server]The statement has been terminated. Insert into "DimClient"("ClientID","ClientName","LastUpdatedDate","AddedDate") Values (?,?,?,?)

 

This time i m expecting update to run instead of doing insert again.

 

Any comments , how can we do UPSERT.

 

Regards

hali

hali11251
6 - Meteoroid

Thank you for the response. You need a primary key and another thing to consider is that to create ODBC  system DSN not user DSN. once you create with system DSN then you can see custom mapping column. 

 

Also if you have identity column in a table then don't create identity column as primary column because alteryx will not able to identify the difference between primary key and identity column.

 

Regards

Hali

hali11251
6 - Meteoroid

 create ODBC system DSN and not User DSN. once you used system DSN then do custom mapping and upsert will work with primary key in the table.

VamsiK
5 - Atom

Pre-SQL, specify the following.

 

use [schema name]

 

For example: use edw

 

This is a bug in 2020.x I think and not sure if it is fixed. 

 

 

Labels