我有一个日期字段代表StartDate使用CalenderExtender和textbox字段代表ID。我将2参数从Code-Behind(ASP.NET)传递给存储过程.....
在表中有4列 ID,StartDate,Enddate和ReturntoWorkDate :
我的需求是如果我从Code-Behind传递参数,它应该与 StartDate,enddate 和 ReturntoWorkDate 进行比较,它应该显示表中的记录。
考试表 ID :001 startdate :12-11-2010 EndDate :12-19-2010 ReturntoWorkDate < / strong>:12-20-2010
我传递的参数 ID :001和 Startdate :12-13-2010
输出: ID :001 || Startdate :12-11-2010 || Enddate :12-19-2010 || ReturntoWorkDate :12-20-2010
以上问题仅需要存储程序
这是代码.....
Alter PROCEDURE [dbo].[sp_SearchLeaveDate]
@employeeid varchar(30),
@leavestartdate varchar(30)
As
Begin
Declare @employee varchar(max)
declare @leavestart varchar(Max)
select @employee = employeeid, @leavestart = leavestartdate from LeaveRequest where employeeid = @employeeid and (between leavestartdate >=@leavestartdate or leaveenddate <= @leavestartdate)
end
任何人都可以帮助我.............
答案 0 :(得分:0)
ALTER PROCEDURE [dbo].[sp_SearchLeaveDate]
@employeeid varchar(30),
@leavestartdate varchar(30)
As
Begin
Declare @employee varchar(max)
declare @leavestart Datetime
set @leavestart = @leavestartdate
select count(*) from LeaveRequest where employeeid = @employeeid and (@leavestart between leavestartdate and returndate) and (status = 'Pending' or status = 'Approved')
End