存储过程参数判断为空问题
ALTER PROCEDURE [dbo].[Pro_SelectItem]
@User_Name varchar(50),
@qItemTime datetime,
@dItemTime datetime
as
if(isnull(@User_Name,'')='' and ISNULL(@qItemTime,'')<>'' and ISNULL(@dItemTime,'')<>'')
begin
select ine.ItemBz,ine.ItemName,ine.Itemint,ine.ItemTime,su.User_Name,itd.ItemName from
ItemName as ine inner join Sys_user as su on ine.Ubz=su.Ubz inner join ItemDate as itd on ine.ItemName=itd.ItemBz
where ine.ItemTime between @qItemTime and @dItemTime
end
if(isnull(@User_Name,'')<>'' and ISNULL(@qItemTime,'')<>'' and ISNULL(@dItemTime,'')<>'')
begin
select ine.ItemBz,ine.ItemName,ine.Itemint,ine.ItemTime,su.User_Name,itd.ItemName from
ItemName as ine inner join Sys_user as su on ine.Ubz=su.Ubz inner join ItemDate as itd on ine.ItemName=itd.ItemBz
where ine.ItemTime between @qItemTime and @dItemTime and su.Ubz=@User_Name
end
if(isnull(@User_Name,'')='' and ISNULL(@qItemTime,'')<>'' and ISNULL(@dItemTime,'')<>'')
begin
print 1
end
if(isnull(@User_Name,'')<>'' and ISNULL(@qItemTime,'')<>'' and ISNULL(@dItemTime,'')<>'')
begin
print 2
end
return 1--表示成功
end
end
这个判断条件 得加一个条件现在
判断 日期中的月份是否与表中的日期月份有相同的
传过来的格式是datetime格式 表中也是日期格式 怎么只截取其中的月份进行比较
求解!!
[其他解释]