尝试在函数中使用 Select 语句时收到错误。错误指出:
消息 444,级别 16,状态 2,过程 JDE_GetWhereClause_test,第 26 行
函数中包含的选择语句无法将数据返回到客户端。
有任何想法吗?
CREATE FUNCTION [dbo].[JDE_GetWhereClause_test]
(
@tablename as varchar
)
RETURNS varchar(max)
AS
BEGIN
-- Declare the return variable here
Declare @ResultVar as varchar(max)
-- Add the T-SQL statements to compute the return value here
set @tablename = 'F0101'
Declare @Sql nvarchar(max)
Declare my_cur cursor for
SELECT fsuser FROM dbo.JDE_ExRowSecurity where fsuser = fsuser;
Declare @fsuser as nchar(15)
open my_cur;
fetch next from my_cur;
while @@fetch_status = 0
begin
fetch next from my_cur into @fsuser;
set @ResultVar += ',' + @fsuser;
end;
close my_cur;
deallocate my_cur;
-- Return the result of the function
RETURN @ResultVar
END