What I am atttemting to do is to get all of the alerts into a single field. I can display the results set, however was thinking of using a loop function to combine all of the results into 1 field.
Here is what I have so far:
I tried to place this into a loop, but now the query takes over 1/2 hour.
How would I fix this to display all of the alerts for this account into a single field?
Here is what I have so far:
Code:
select top 1 @id = AlertCode from AccountAlert
Where AccountKey = 6706
And StopDate Is Null
Order By AlertCode
set @Accountalert = @ID
I tried to place this into a loop, but now the query takes over 1/2 hour.
Code:
While @id is not null
begin
set @accountAlert = @accountalert + ', ' + @ID
select top 1 @id = Alertcode from Accountalert
where Alertcode > @id and AccountKey = 6706
And StopDate Is Null
Order By AlertCode
end
Select @accountalert