Incorrect syntax near 'Code' when using Insert Data Table

I’ve successfully connected to SQL Server and the workflow runs through several inserts before I get to the error. However, when inserting to this table I get an error:

“.Net SqlClient Data Provider - Incorrect syntax near ‘Code’.”

The only time the word ‘code’ appears in this table is one field named ‘Edit Dist Code’. In SQL Server, I have the field set up as text/allow nulls. Does anyone have any idea what might be causing this error?

1 Like

Hi @bcarp,

can you please write the complete sql query which you are using to insert the data in the dt.
possible chance that the issue could be due to a missing quotes(") in the statement.

Hi @Manoj_Batra,

I’m not using an sql query. I’m using the insert data table activity.

@ClaytonM any ideas?

This could be due to invalid column name.try to change the column name or write column name in quotes. if the column name contains spaces try to remove it.

1 Like

This seems a bug on the insert activity. Normally, when you have column with space, You should enclosed it in a Bracket [Edit Dist Code].

Your workaround maybe is to remove the space in the column or using a Execute Non Query: Insert Statement then enclosing the Column with space in bracket.

1 Like

@Manoj_Batra You were right. It’s because the column name has spaces in it. Unfortunately, this is a huge workflow that had over 300 instances of this field in it along with many other fields. Luckily, I was able to open the .xaml in notepad++, find & replace the field names and everything works great now. Thank you!

2 Likes

That’s Great :slightly_smiling_face:

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.