本文介绍了sql函数总是返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友,
我正在使用sqlserver函数,该函数一直工作到昨天。但是每当我使用它时,返回null avlues。请帮我。这是批量生产,但仍然无法正常运行。
Hello friends ,
I am using a sqlserver function that was working file till yesterday. But returning null avlues today whenever i am using it. Please help me. This is wroking as batch but still not working as a function.
create FUNCTION [dbo].[planame](@custid int, @dBillDate datetime)
RETURNS VARCHAR(MAX)
BEGIN
--RETURN LTRIM(RTRIM(@string))
declare @planname VARCHAR(MAX)
if exists ( select top 1 tp.planName from tNetServicePlans tp
inner join tnetserviceplanshistroy ch on ch.planId=tp.planId
--inner join tnetbill b on b.custid=ch.custid
--where cast(ch.updatedate as date)<=cast(@dBillDate as date)
where convert(datetime,ch.updatedate,105)<=convert(datetime,'4/1/2013',105)
and ch.custid=1
order by ch.updatedate desc
)
begin
select top 1 @planname=tp.planName from tNetServicePlans tp
inner join tnetserviceplanshistroy ch on ch.planId=tp.planId
--inner join tnetbill b on b.custid=ch.custid
where convert(datetime,ch.updatedate,105)<=convert(datetime,'4/1/2013',105)
and ch.custid=1
order by ch.updatedate desc
end
return @planname
END
请帮帮我朋友。
Please help me friends.
推荐答案
这篇关于sql函数总是返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!