读书人

函数返回table?解决方法

发布时间: 2012-01-26 19:40:46 作者: rapoo

函数返回table?
--函数的建立是正确的
if(object_id( 'test ')is not null)
drop function test
go
create function test()
returns @t table(A1 varchar(20),A2 varchar(20),A3 varchar(1000))
as
begin
insert into @t
select A1,A2,A3 from A
return
end
go

--这句调用不对,报错
select dbo.test() --from A where A1= 'c '
请问如何调用返回table的函数呢?

[解决办法]
select * from dbo.test()
[解决办法]
select * from dbo.test()

读书人网 >SQL Server

热点推荐