日期:2014-05-16  浏览次数:21290 次

SQL command not properly ended
这是我的自定义的一个方法
create function aa(@upperid int)
returns @t table (id int,upperid int,level int)
as
begin
declare @i int
set @i=1
insert into @t
select *,@i from t where upperid=@upperid
while @@rowcount>0
begin
set @i=@i+1
insert into @t
select a.*,@i from t a left join @t b on a.upperid=b.id
where b.level=@i-1
end
return
end

我创建的一个简单的表
SQL> select * from t;
 
                                     ID                                 UPPERID
--------------------------------------- ---------------------------------------
                                      1                                       2
                                      3                                       2
                                      4                                       1
                                      5                                       3

最后我执行 select * from budgettest.aa(1) 就报错  就指教
------最佳解决方案--------------------
发错版了吧,到sql server版问比较合适。
这不是oracle function的语句写法。
------其他解决方案--------------------
 select * from aa(1) 这么不行么
------其他解决方案--------------------
select * from table(aa(1));
------其他解决方案--------------------
引用:
 select * from aa(1) 这么不行么

我的方法创建之后 名字图标下显示红叉叉 
我不知道方法那错啦
------其他解决方案--------------------