读书人

FUNCTION 返回TABLE有关问题

发布时间: 2012-01-09 21:05:42 作者: rapoo

FUNCTION 返回TABLE问题
CREATE FUNCTION ExecSQL(@strSQL NVARCHAR(5000))
RETURNS TABLE
AS
RETURN
(
@strSQL
);
GO

我想通过外边传SQL,返回Table


[解决办法]
no way
[解决办法]
函面不可以 exec(@strSql)
[解决办法]
if object_id( 'Ptest1 ', 'p ') is not null
drop proc ptest1
create proc ptest1
@sid int,@str int
as
if object_id( 'test1 ') is not null
drop table test1
create table test1(
id int,
mon int
)
insert into test1 values(@sid,@str)

exec ptest1 1,2

select * from test1

id mon
----------- -----------
1 2

[解决办法]
存储过程如LS即可
函数则不成

读书人网 >SQL Server

热点推荐