我在运行此程序时遇到问题,它让我错误地尝试解析' ok' to int但我不希望结果为int。
DECLARE @result_var nvarchar(max)
DECLARE @ParmDefinition NVARCHAR(max)
EXECUTE Sp_executesql
@definition,
@ParmDefinition,
@result_var = @result_var output;
正在更改@result_var
SET @result_var = ''ok'';
DECLARE @cursor CURSOR,
@name VARCHAR(100)
SET @cursor = CURSOR FOR
SELECT [NAME]
FROM [iflvs08].mds.mdm.lv_budget_employee
OPEN @cursor
FETCH next FROM @cursor INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN
IF RIGHT(@Name, 1) = '' ''
begin
IF (Len(@result_var) > 1)
SET @result_var = @result_var + '','' + @name
ELSE
SET @result_var = @name
END
FETCH next FROM @cursor INTO @name
END
答案 0 :(得分:1)
看起来你声明但没有设置@ParmDefinition变量。 它应该是这样的:
DECLARE @ParmDefinition NVARCHAR(max)
SET @ParmDefinition = N'@result_var nvarchar(max) OUTPUT';
EXECUTE Sp_executesql
@definition,
@ParmDefinition,
@result_var=@result_var output ;