日期:2014-05-17 浏览次数:20534 次
use tempdb go create table test (name char(10), sdate datetime, edate datetime, Ewstatus int --0:在职;1:离职 ) insert into test values('a','2011-03-01','2011-08-31',0) insert into test values('a','2011-09-01','2999-12-31',1) insert into test values('b','2011-03-01','2099-12-31',0) declare @leavedate datetime='2011-06-01'--查询时间 select name ,Ewstatus from test where @leavedate between sdate and edate and Ewstatus=0