-2
DECLARE @x nvarchar(max)
DECLARE @Employee bigint
DECLARE @StartDate date
DECLARE @EndDate date
SET @x = 'Select Distinct Att.Status
,ED.StartDate
,ED.EndDate
,u.FirstName
,u.Department
,ED.LeaveDays
from EmployeeLeaveDetails ED
JOIN Employee e on ED.Employee = e.Employee
and ED.IsDeleted = 0
and e.IsDeleted = 0
JOIN Attendance a on e.Employee = a.Employee
LEFT JOIN AttendanceStatus Att on CAST(a.Status as nvarchar) = Att.Status
and a.IsDeleted = 0
and Att.IsDeleted = 0
and Att.IsVacation = 1
JOIN Users u on e.Users = u.Users
and u.IsDeleted = 0
Where ED.Employee = ' +CAST(293 as nvarchar)+ '
and ED.StartDate = '+CAST('2016-01-01' as nvarchar)+'
and ED.EndDate ='+CAST('2016-01-04' as nvarchar)+'
group by Att.Status
,ED.StartDate
,ED.EndDate
,u.FirstName
,u.Department
,ED.LeaveDays'
这是我的后端codeI是无法转换它,每次它给了我“操作数类型冲突:日期与诠释不兼容”这一错误...请帮助 – Mac
我newto堆栈溢出,请原谅我 – Mac
你可以发布你在这个查询中使用的表的表结构吗? –