【发布时间】:2014-11-19 02:29:53
【问题描述】:
您好,当我尝试使用以下查询获取结果 MSDB 和我的本地 DB DXSH 时。 我收到错误消息
"Msg 116, Level 16, State 1, Line 12 当子查询不使用 EXISTS 引入时,选择列表中只能指定一个表达式。"
select (SELECT StoreID FROM dxsh..Store),(select distinct j.Name as "Job Name",h.run_date as LastStatusDate,case h.run_status
when 0 then 'Failed'
when 1 then 'Successful'
when 3 then 'Cancelled'
when 4 then 'Executing'
end as JobStatus
from msdb.dbo.sysJobHistory h, msdb.dbo.sysJobs j
where j.job_id = h.job_id and h.run_date = (select max(hi.run_date) from msdb.dbo.sysJobHistory hi where h.job_id = hi.job_id)
and h.run_status = 0
and J.name = 'Clear Trays and Trolleys')
考虑到 Storeid 的预期结果:111
111 清除托盘和手推车 20141119 失败
请帮忙
【问题讨论】:
-
这是错误的:
select (SELECT StoreID FROM dxsh..Store),...应该类似于select storeID,...然后在from中有表Store并将其与其他表sysJobs和sysJobsHistory连接起来
标签: sql-server