Skip to main content

Hi Everyone

I have a sharepoint list which retutns me some name; I store this name in a collection

After that; I'd like to execute a sql querry like that:

Select [Role], [Name],[Incoming]

FROM MyDB

WHERE Name IN mycollection

When I execute this WF; I get the following error message: Incorrect Syntax near 'Bob' (Bob is a name which is in my collection)

Any idea of what I'm doing wrong?

Thanks

The SQL syntax for a where .. in is

Where Name in ('Firstname','Secondname','Thirdname')

So you would need to Join your collection values with ',' into a string and add (' at the start and ') at the end

You should then be able to use this string in your Where expression


Sorry for the delay, I built a string and I get the following string:

 

('Bob','Julien','Tom')

So it's exactly what I need but during my querry I get the following error message:

Incorrect syntax near 'Bob'.

And here my query :

SELECT Role]
,,Name]
FROM dbo]..Stakeholders]
WHERE '{Common:ProjectUID}' = ProjectUID AND Name] IN {WorkflowVariable:MName}

If I replace  {WorkflowVariable:MName} by  ('Bob','Julien','Tom')

Any idea of what I'm doing wrong?


Try this

set MName to 'Bob','Julien','Tom'

Then make your query

SELECT [Role]
 ,,Name]
 FROM Mdbo].]Stakeholders]
 WHERE '{Common:ProjectUID}' = ProjectUID AND NName] IN ({WorkflowVariable:MName})

That is, make the brackets part of the query and not part of the string


Reply