Showing results for 
Search instead for 
Did you mean: 
Nintex Newbie

SQL Query within a loop

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

Tags (2)
0 Kudos