在选择列表中是没有用EXISTS引入子查询时,可以指定只有一个表达式
INSERT INTO [dbo].[dm_pmp_scores]
([fosid],[fycode],[empid],[fullname],[jobgrade],[meritrate],[perfrate],
[potband],[hrremarks],[isdirty],criticality,promotability,PostRanking,iscommited)
select '75DA940A-5436-4866-8D44-FE1890E2C0F6','FY0607','tt0042',
(select distinct fullname,jobGrade from [vw_pat_users] where EmployeeID='tt0042'),'A','B','Band 2','','0','','','',0
报错
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS
------解决方案--------------------select distinct fullname,jobGrade from [vw_pat_users] where EmployeeID='tt0042'得到的是一个集合 所以有问题
这样的赋值只能是单个的值。
------解决方案--------------------SQL code
INSERT INTO [dbo].[dm_pmp_scores]
([fosid],[fycode],[empid],[fullname],[jobgrade],[meritrate],[perfrate],
[potband],[hrremarks],[isdirty],criticality,promotability,PostRanking,iscommited)
select distinct '75DA940A-5436-4866-8D44-FE1890E2C0F6','FY0607','tt0042', fullname,jobGrade ,'A','B','Band 2','','0','','','',0
from [vw_pat_users] where EmployeeID='tt0042'