17,078
社区成员
发帖
与我相关
我的任务
分享
if not object_id('Tempdb..T_20081010') is null
drop table T_20081010
Go
Create table T_20081010([ID] int,[S_ID] nvarchar(1),[P_ID] nvarchar(10))
Insert T_20081010
select 1,'a','2009-02-00' union all
select 2,'a','2009-02-28' union all
select 3,'b','2009-01-28' union all
select 4,'b','2009-01-25' union all
select 5,'b','2009-02-27' union all
select 6,'b','2009-02-26'
Go
--Select * from T_20081010
declare @P int
set @P=''
select * from T_20081010
where (case when (id=@p) then 1 when @p='' then 1 else 0 end)=1