Use variable in Execute Query

hi bro,

In query I want use as variable 20220601’,‘20220731 ? how can I change it everyday ?
“exec [sp_VIEW070_ExportExcel] ‘%’,’%‘,’%‘,’%‘,’%‘,‘20220601’,‘20220731’,’%‘,‘V’,’%'”


write your query as
“exec [sp_VIEW070_ExportExcel] ‘%’,’%‘,’%‘,’%‘,’%‘,‘@var1 ’,‘@var2 ’,’%‘,‘V’,’%'”

then you can create var1 and var2 on the Parameters collection in the execute query properties

Annother not so elegant solution is to use basic sting manipulation, something like

“exec [sp_VIEW070_ExportExcel] ‘%’,’%‘,’%‘,’%‘,’%‘,‘" + var1 + "’,‘" + var2 + " ’,’%‘,‘V’,’%'”

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.