该条SQL语句为什么报错

来源:百度知道 编辑:UC知道 时间:2024/05/27 13:49:11
CREATE FUNCTION ProcessPayroll1(@hoursPerWeek Int)
RETURNS Int
AS
IF SIGN(@hoursPerWeek-40)>0
BEGIN
PRINT '工作超时'+@hoursPerWeek-40
RETURN @hoursPerWeek-40
END
ELSE
PRINT '工作未超时'

消息 156,级别 15,状态 1,过程 ProcessPayroll1,第 5 行
关键字 'IF' 附近有语法错误。
Write a function named ProcessPayroll1 that takes the number of hours worked in a week. Then the function returns a value that represents overtime. If the employee worked less than 40 hours, there is no overtime. If the employee worked for more than 40 hours, the number over 40 is considered overtime

怎样实现这个SQL 函数

无载体怎么打印。函数里面只有返回值,没有打印的。

print只能是一个事件,但是它又继承的哪个对象呢?

IF (SIGN(@hoursPerWeek-40)>0 )

CREATE FUNCTION ProcessPayroll1(@hoursPerWeek Int)
RETURNS Int

begin
IF SIGN(@hoursPerWeek-40)>0
BEGIN
return '工作超时'
RETURN @hoursPerWeek-40
end
else
begin
return '工作未超时'
end
return ''
end