相关代码 |
|
/* 文件名称: UDFDemo3.sql */ USE 北风贸易 GO IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'dbo.udf_Tax') and xtype = N'FN') DROP FUNCTION dbo.udf_Tax GO -- 建立一个用来计算出应缴税额的用户自定义函数 CREATE FUNCTION dbo.udf_Tax (@income money) RETURNS money AS BEGIN DECLARE @tax money SET @tax = @income * CASE WHEN (@income >= 60000) THEN 0.35 WHEN (@income >= 50000) THEN 0.25 WHEN (@income >= 40000) THEN 0.2 WHEN (@income >= 20000) THEN 0.15 ELSE 0.01 END RETURN @tax END GO
相关资源 |
|