create function mysal(@sal decimal(8,2))
returns @table table
(
@eid int,
@firstname varchar(20),
@salary decimal(8,2),
@doj date
)
as
begin
insert @table
select * from employees where salary>@sal;
return
end
Error: Msg 102, Level 15, State 1, Procedure mysal, Line 5 Incorrect syntax near '@eid'.
错误:消息102,级别15,状态1,过程mysal,第5行'@eid'附近的语法不正确。
1 个解决方案
#1
1
The return table column names should not have @ in them, and the ; should be removed.
返回表列名称中不应包含@,并且;应该删除。
create function mysal(@sal decimal(8,2))
returns @table table
(
eid int,
firstname varchar(20),
salary decimal(8,2),
doj date
)
as
begin
insert @table
select * from employees where salary > @sal
return
end
Just a warning, this kind of multi-statement UDFs can be really bad for performance and using "Select *" causes your function to break if someone adds a new column to the table.
只是一个警告,这种多语句UDF可能对性能非常不利,如果有人在表中添加新列,使用“Select *”会导致函数中断。
#1
1
The return table column names should not have @ in them, and the ; should be removed.
返回表列名称中不应包含@,并且;应该删除。
create function mysal(@sal decimal(8,2))
returns @table table
(
eid int,
firstname varchar(20),
salary decimal(8,2),
doj date
)
as
begin
insert @table
select * from employees where salary > @sal
return
end
Just a warning, this kind of multi-statement UDFs can be really bad for performance and using "Select *" causes your function to break if someone adds a new column to the table.
只是一个警告,这种多语句UDF可能对性能非常不利,如果有人在表中添加新列,使用“Select *”会导致函数中断。