我想用表变量中的参数调用SQL函数,但是当我调用它时我得到了错误
子查询返回的值超过1个
因为表有多行。如何从表变量中逐行调用函数?
这是我的代码:
DECLARE @FromDate NVARCHAR(10) = '20150809',
@ToDate NVARCHAR(10) = '20150815',
@EmpID NVARCHAR(6)= '000752'
DECLARE @AttendanceTable TABLE(date NVARCHAR(30),Funckey NVARCHAR(10))
insert into @AttendanceTable(date,Funckey) SELECT date,Funckey from PERS_Attendance WHERE DATE between convert(date,@fromDate) AND CONVERT(Date,@toDate)
select * FROM @AttendanceTable
select dbo.SM_GetScheduleIn(@EmpID,(select date from @AttendanceTable))
答案 0 :(得分:0)
select dbo.SM_GetScheduleIn(@EmpID,(select date from @AttendanceTable))
应该是
select dbo.SM_GetScheduleIn(@EmpID,date) from @AttendanceTable