SQL String Parameter Issues

I have posted on the forum about this issue before but I am still looking for help. I am trying to pass a list of strings into a query and use the “IN” clause in SQL to go through the list. However, since I am passing a string in, the quotes around the string seem to be causing an issue for the query.

For example, WFIDString would be (‘0000000’ , ‘1111111’ , ‘2222222’). When I run the query without the variable/parameter, this query works great. But when I try to pass the string in as a variable it fails to run, I think because of the quotes that surround a string.

Any thoughts? Thanks in advance

@jpreziuso Can you tell us what is the Error that you get ?

Cheers

The error from the query is “Incorrect syntax near ‘@WFID_STRING’”

I think this is because of the double quotes that end up around a string variable

I will look into this, thank you

Have you tested to remove the @ from the parameter name? I believe you should only have @ in the SQL string.

I have not tested that as I have used variables before with the @ symbol. But I will try that

1 Like

Good spot. The parameter name should be without “@”. Anyway it will not solve the problem because “IN @parameter” is not supported - in TSQL.

Cheers

1 Like

Yes I changed the parameter name to not include the @ and I added it to the query to look like this:

But correct, it did not solve the IN issue. I still got an error saying Incorrect syntax near ‘@WFID_STRING

Cheers

1 Like