当前位置: 代码迷 >> Sql Server >> FUNCTION 返回TABLE有关问题
  详细解决方案

FUNCTION 返回TABLE有关问题

热度:139   发布时间:2016-04-27 19:38:09.0
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即可
函数则不成
  相关解决方案