Incorrect sql

Hello everyone!
if I watch from message box row.item(2).ToString - IT correct: 200120-J003682227-N00151646137
I have sql: “USE " + SQLDB + " Select InventSum.ITEMID, InventDim.INVENTBATCHID inner Join InventDim On InventSum.INVENTDIMID = InventDim.INVENTDIMID Where InventSum.ITEMID =” + row.item(1).ToString + "And InventDim.INVENTBATCHID = " + row.item(2).ToString + "

Where row.item(2).ToString = “200120-J003682227-N00151646137”

But I have error in SQL: Execute Query: Invalid column name ‘J003682227’.
Invalid column name ‘N00151646137’.

Hy @RPA3,

Some questions:

Did you use the Connect Database Activity?

I have sql: “USE " + SQLDB + " (I dont understand this, the sql statement must start with select

" And InventDim.INVENTBATCHID: an space is missing.

Can you show a picture of your workflow?


Hi @RPA3,

You can remove use and sqlbd here not required to mandatory any way we connect database activity

The USE Statement is used to select a database and perform SQL operations into that database. The database remains default until end of session or execution of another USE statement with some other database.

How I can solve this problem?

Do you have sql management studio?
Yes paste your query and check any spaces or any mistake or write any store procedure insted of this query put in to sp pass parameter

No, I haven’t

can you share full query or xaml file

Take 3 assign activity pass row to variable and use this variable for inside query

OperatingBusinessUnitSettings.OPERATINGUNITNUMBER From inventSum inner Join InventDim On InventSum.INVENTDIMID = InventDim.INVENTDIMID
inner Join inventLocation On inventLocation.INVENTLOCATIONID = inventDim.INVENTLOCATIONID
inner Join DirPartyTable On DirPartyTable.RECID = inventLocation.BUSINESSUNIT
inner Join OperatingBusinessUnitSettings
On OperatingBusinessUnitSettings.OperatingBusinessUnit = DirPartyTable.RECID Where
InventSum.ITEMID =”+ row.item(1).ToString +" And OperatingBusinessUnitSettings.OPERATINGUNITNUMBER =“+ row.item(0).ToString +
“And InventSum.PHYSICALINVENT >=” + row.item(3).ToString +" And InventDim.ITEMSTATUS = ‘001’ And InventSum.PHYSICALINVENT != ‘0’
And InventDim.INVENTBATCHID =" + batch.ToString + " order by InventSum.PHYSICALINVENT desc"

It is not work.

You passed variable inside query?
Same error you are getting

Write please, what I need use?

Assign activities

Use this Variable inside query

I did it. Error