我有两个标签mangers
(没有名字)和Employees
(有所有名字)。
我想让函数获得员工姓名并返回他的经理姓名
create or alter function funTest (@employee varchar(max))
returns varchar(max)
as
begin
declare @manager varchar(max)
select @manager = (select @manager = m.empname from employees e,employees m , departments d
where e.empid=d.managerid and .deptid=d.deptid
and @employees =e.empname)
return @manager
end
不是:我是通过procedure
答案 0 :(得分:0)
是的,这是可能的,但你可能需要一些小改动,试试这个
CREATE FUNCTION funTest
(
@employee varchar(max)
)
returns varchar(max)
as
begin
declare @manager varchar(max)
select
@manager = m.empname from employees e,employees m , departments d
where e.deptid = d.deptid and d.managerid=m.empid
and e.empname=@employee
return @manager
end