AnsweredAssumed Answered

SQL Query within a loop

Question asked by orangejuice on Feb 28, 2018

Hi There

 

I've added a sql query in a loop. The loop iterates an array of student reference and student course. However only the first item is returned. I think this could be because the sql query fails the 2nd time, oddly no error is reported.
For instance when I add 3 pairs of data, the 3 pairs are logged correctly but no output for the last 2 pairs.

 


declare @studRef as nvarchar(30)
declare @CourseRef as nvarchar(30)

set @studRef = '{WorkflowVariable:getStudentRef}'
set @CourseRef = '{WorkflowVariable:getCourseRef}'


declare @sql as nvarchar(MAX)
set @sql = dbo.GetViewSQL('wf.rc.wdw.withdrawal.Audit')

exec sp_executesql @sql, N'@studRef nvarchar(4000),@CourseRef nvarchar(4000)', @studRef, @CourseRef

Outcomes