34,590
社区成员
发帖
与我相关
我的任务
分享
if object_id('p_cx') is not null
drop proc p_cx
go
create proc p_cx
@start varchar(20),----riqi的起始范围
@end varchar(20), ----riqi的最后范围
@kahao varchar(20)------kahao的值
as
begin
declare @str varchar(max)
set @str='select * from vipshuru where where 1=1'
if isnull(@start,'')<>''
begin
set @str=@str+' and riqi between '''+ltrim(@start)+''' and '''+ltrim(@end)+''''
end
if ISNULL(@kahao,'')<>''
begin
set @str=@str+'and kahao like ''%'+@kahao+'%'''
end
set @str=@str+' order by riqi desc,shijian desc'
exec(@str)
end
go
exec p_cx '2011-08-29','2011-08-29',''
if object_id('p_cx') in not null
drop proc p_cx
go
create proc p_cx
@start varchar(20),----riqi的起始范围
@end varchar(20), ----riqi的最后范围
@kahao varchar(20)------kahao的值
as
begin
declare @str varchar(max)
set @str='select * from vipshuru where where 1=1'
if isnull(@start,'')<>''
begin
set @str=@str+' and riqi between '+ltrim(@start)+' and '+ltrim(@end)+''
end
if ISNULL(@kahao,'')<>''
begin
set @str=@str+'and kahao like ''%'+@kahao+'%'''
end
set @str=@str+'order by riqi desc,shijian desc'
print(@str)
end
--调用
exec p_cx '','',''---riqi的起始范围,riqi的最后范围,kahao的值
在前面加上
if object_id('p_cx') in not null
drop proc p_cx
go
create proc p_cx
@start varchar(20),----riqi的起始范围
@end varchar(20), ----riqi的最后范围
@kahao varchar(20)------kahao的值
as
begin
declare @str varchar(max)
set @str='select * from vipshuru where where 1=1'
if isnull(@start,'')<>''
begin
set @str=@str+' and riqi between '+@start+' and '+@end+''
end
if ISNULL(@kahao,'')<>''
begin
set @str=@str+'and kahao like ''%'+@kahao+'%'''
end
set @str=@str+'order by riqi desc,shijian desc'
print(@str)
end
--调用
exec p_cx '','',''---riqi的起始范围,riqi的最后范围,kahao的值
select * from vipshuru where (isnull(riqi,'')=@dt1 or riqi between @dt1 and @dt2) and kahao like '%%' order by riqi desc,shijian des
create proc p_cx
@start varchar(20),----riqi的起始范围
@end varchar(20), ----riqi的最后范围
@kahao varchar(20)------kahao的值
as
begin
declare @str varchar(max)
set @str='select * from vipshuru where where 1=1'
if isnull(@start,'')<>''
begin
set @str=@str+' and riqi between '+@start+' and '+@end+''
end
if ISNULL(@kahao,'')<>''
begin
set @str=@str+'and kahao like ''%'+@kahao+'%'''
end
set @str=@str+'order by riqi desc,shijian desc'
exec(@str)
end
--调用
exec p_cx '','',''---不加条件(查看全部)