Page 1 of 1

Question concerning using a variable in a SQL query.

Posted: Thu May 09, 2024 7:30 am
by basisclay
Hi everyone. I recently found the ability to define a variable and declare that it may be used as a SQL parameter. My original query looked like this: SELECT * FROM customers. WHERE customerID="@custID"

I also added a parameter named @custID of type int.

I eliminated the parameter and then added a variable named @custID with the checkbox "Allow using as SQL parameter". The report fails to run in the designer and crashes due to the "@" symbol.
How do you utilize a variable in your query?

Re: Question concerning using a variable in a SQL query.

Posted: Thu May 09, 2024 1:03 pm
by JohnW
In the report data query you still need the sql parameter. You then assign the parameter value in the parameter Expression property to the variable you created.

Re: Question concerning using a variable in a SQL query.

Posted: Fri May 10, 2024 1:16 am
by basisclay
Thanks for your supports, JohnW.