存储过程不能返回一个TABLE类型的表吗?
我在存储过程内部构建了一个TABLE在其中对表进行数据添加结果return这个table提示:必须声明标量变量"@Table"代码:ALTERPROCEDURE[dbo]...
我在存储过程内部构建了一个TABLE 在其中对表进行数据添加 结果return这个table 提示:必须声明标量变量 "@Table"
代码:
ALTER PROCEDURE [dbo].[P_View_Project_Level]
As
declare @id int
declare @level varchar(20)
DECLARE @Table TABLE (
ID int ,
PKID varchar(50),
level varchar(20)
)
insert @Table
SELECT MAX(ID) AS id, PKID,null
FROM dbo.Project_Level GROUP BY PKID
declare cursor1 cursor for
select id from @Table
open cursor1
fetch next from cursor1 into @id
while @@fetch_status=0
begin
set @level= (select level from Project_Level where ID=@id)
update @Table set level=@level
where id=@id
fetch next from cursor1 into @id
end
close cursor1
deallocate cursor1
return @Table 展开
代码:
ALTER PROCEDURE [dbo].[P_View_Project_Level]
As
declare @id int
declare @level varchar(20)
DECLARE @Table TABLE (
ID int ,
PKID varchar(50),
level varchar(20)
)
insert @Table
SELECT MAX(ID) AS id, PKID,null
FROM dbo.Project_Level GROUP BY PKID
declare cursor1 cursor for
select id from @Table
open cursor1
fetch next from cursor1 into @id
while @@fetch_status=0
begin
set @level= (select level from Project_Level where ID=@id)
update @Table set level=@level
where id=@id
fetch next from cursor1 into @id
end
close cursor1
deallocate cursor1
return @Table 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询