我在将job_num_to_run变量设置为sql脚本中的实际job_id时遇到问题。下面的示例将要运行的作业数设置为字符串文字“select max ...”并且不评估该值。我尝试了许多不同的方法但没有成功。任何帮助将不胜感激。谢谢
def job_num_to_run = select max(job_id) from job_table;
update job_table
set processed = 'Y' where job_id = &job_num_to_run;
答案 0 :(得分:1)
DECLARE @job_num_to_run INT = select max(job_id) from job_table;
update job_table
set processed = 'Y'
where job_id = @job_num_to_run;
INT可以是job_id的数据类型
答案 1 :(得分:1)
Update job_table set processed = 'Y' where job_id = (select max(job_id) from job_table)