调试时,@ buildEvents在第一次进入循环时会被填充,但下次再也不会被连接起来。这可能在游标内吗?
OPEN @BusinessCursor;
FETCH NEXT FROM @BusinessCursor INTO @BusinessName;
WHILE @@FETCH_STATUS = 0
BEGIN
set @buildEvents = @buildEvents + @BusinessName
FETCH NEXT FROM @BusinessCursor INTO @BusinessName;
END
CLOSE @BusinessCursor;
DEALLOCATE @BusinessCursor;
select @buildEvents
return
关于如何让@buildEvents与@BusinessName连接的任何想法?通过的数据是电子邮件的html数据。
答案 0 :(得分:0)
你可能不会做两件事之一:
当您声明@buildEvents
为其分配一个空字符串时:
declare @buildEvents varchar(max) = ''
在循环中检查null
中的@BusinessName
:
set @buildEvents = @buildEvents + ISNULL(@BusinessName, '')