Insert data into sql table with auto increment column

Hello Folks,

I’m trying to insert data into a SQL table. I’ve got the following error

Execute Non Query: Cannot insert the value NULL into column ‘id’, table ‘Database.dbo.table_name’; column does not allow nulls. INSERT fails.\r\nThe statement has been terminated.

I’ve found that the table is having id column as

  • auto-increment.
  • Primary key

Here is my SQL query FYI

> string.Format("INSERT INTO table_name ([c_bankFeeAmount],[c_GLCode],[c_remark],[c_status],[c_tranType]) values ( '{0}','{1}' ,'{2}','{3}','{4}')",vBankFeeAmount, vGLCode, vRemark,"Extracted","Chg")

any help would be appreciated
Thanks

Hello @kgmaheshwari,

Use assign activity to auto increment numbers in for each and pass that variable to values

2 Likes