08-01-2022 07:27 AM
Hi,
I have a long SQL string, in which a user selected value from a combo box should be passed in several lines.
I could use Concatenate to combine the combo box value with other part of SQL string but since the string is long and the combo value is supposed to appear several times in between I want to preferably avoid this method. Is there any way to catch the combo box selected value in a text way programming so to I give it in the SQL string?
Cheers
08-01-2022 07:35 AM
Hi Hasamon,
@Hasamon wrote:
I have a long SQL string, in which a user selected value from a combo box should be passed in several lines.
I could use Concatenate to combine the combo box value with other part of SQL string but since the string is long and the combo value is supposed to appear several times in between I want to preferably avoid this method. Is there any way to catch the combo box selected value in a text way programming so to I give it in the SQL string?
08-01-2022 08:15 AM
@Hasamon wrote:
but since the string is long and the combo value is supposed to appear several times in between
This just screams "Use Format String" to me. You can use something like "%1$s" to repeat using the same input (the first value in this example).
08-23-2022 01:56 AM - edited 08-23-2022 01:57 AM
Thanks, I was looking for something like this. But using this format, where should I replace my input?
Could you elaborate it a little bit?
For example, given the below query:
SELECT
*
From dbo.RESULT
WHERE RESULT.Value1 > X
If I want to pass value X as an input, how should I rewrite this string?
08-23-2022 06:34 AM
You just replace the "X" with the format. Assuming your value is an integer, your example string would just be:
SELECT
*
From dbo.RESULT
WHERE RESULT.Value1 > %d