我有两个子表1.借款人列表,2。返回列表。
我在返回列表表格中有以下字段:
1.RETURNLISTID-->PKEY
2.MEMBERSHIPID -->FKEY
3.BOOKREFID--FKEY
4.MEMBERFULLNAME-->CALCULATED FIELD(FOR THE CORRESPONDING MEMBERSHIPID GET VALUE FROM MEMBERS TABLE)
5.BORROWDATE-->CALCULATED FIELD(FOR THE CORRESPONDING MEMBERSHIPID,BOOKREFID GET VALUE FROM BORROWERLIST TABLE)
6.ACTUALRETURNDATE--> CALCULATED FIELD(FOR THE CORRESPONDING MEMBERSHIPID,BOOKREFID GET VALUE FROM BORROWERLIST TABLE)
7.USERRETURNDATE-->USER WILL ENTER
8.FINEAMT-->IT SHOULD BE A CALCULATED FIELD.I HAVE CREATED A FUNCTION.
我创建了一个使用ACTUALRETURNDATE和USERRETURNDATE来计算fineamt的函数。当我在现场调用我的功能时,我感到错误。
所以,我怀疑是否可以使用一个计算字段来运行?
在下面找到我的功能。
create function dbo.GETFINEAMT(@ACTUALRETURNDATE DATETIME ,@USERRETURNDATE DATETIME)
RETURNS INT
AS
BEGIN
DECLARE @FINEAMT INT
DECLARE @DATEDIFF INT
SET @DATEDIFF=CONVERT(INT,(DATEDIFF(DD,'@ACTUALRETURNDATE','@USERRETURNDATE')))
SET @DATEDIFF = ABS(@DATEDIFF)
SET @FINEAMT=@DATEDIFF *10
RETURN @FINEAMT
END
GO
答案 0 :(得分:0)
如果所有计算列值都来自UDF,那么你必须在某处犯错。所以你会看到你的代码。
看到这个直接的抛出错误,
Declare @t table(col int,col2 as col+1 PERSISTED,col3 as col2+1)
insert into @t values(1)
select * from @t