I have a stored procedure that accepts a string parameter, a comma separated list of required column names that the SP should check a particular table and make sure those columns have data in them... If any record has missing data in those columns the sp should return the recordID and which columns having missing data.
I'm having trouble constructing the final query. I already split the comma separated list into a table variable. and am using a cursor to through each required column
DECLARE columnCursor CURSOR
FOR SELECT * FROM @columnsTable
OPEN columnCursor
DECLARE @currentColumnName nvarchar(256);
FETCH NEXT FROM columnCursor INTO @currentColumnName
WHILE(@@FETCH_STATUS = 0)
BEGIN
....
FETCH NEXT FROM columnCursor INTO @currentColumnName
END