SQL數(shù)據(jù)庫之--------銷售有效期控制

IF?
EXISTS (SELECT * FROM sys.objects WHERE object_id =
OBJECT_ID(N'[dbo].[isxs限效期]') AND type in (N'FN', N'IF', N'TF', N'FS',
N'FT'))
DROP FUNCTION [dbo].[isxs限效期]
GO
create FUNCTION [dbo].[isxs限效期](@jzr char(10),@xq int)
RETURNS int
AS
BEGIN
?? ?-- @返回 = 0 通過
?? ?-- @返回 = 1 不通過 select dbo.isxs限效期(20230106,'0010') select dbo.f有效天數(shù)(20230106)
?? ?declare @返回 int
--?? ?select @ygbh=@jzr
?? ?select @xq=dbo.f有效天數(shù)(@xq)
?? ?if @xq<=180 and @jzr<>'0099'?? ??? ?
?? ??? ?select? @返回=1
?? ?if @xq>=30 and @jzr='0070'
?? ??? ?select? @返回=0
?? ?if @xq>=7 and @jzr='0099'
?? ??? ?select? @返回=0
?? ?if @xq>=180
?? ??? ?select? @返回=0
?? ?return? isnull(@返回,2)
end
---------浪嘉程序之應(yīng)用 ?? 效期小于180天禁止銷售

value(runsql("select dbo.isxs限效期('"+__操作員號+"',"+string(銷售單_效期)+")"))=0