Need to edge out the competition for your dream job? Train for certifications today.
-- starting with the variables you will need in the processing part
declare @code int
-- here is the table variable definition, which lives only for the duration of the run and is cleaned up automatically
-- for "small" results, it will stay purely in memory; larger sets may be "stored" in the temp database
declare @c table ( code int )
-- fill the table with data, update your select as you need it
-- if your process requires some "order" in the processing, still an ORDER BY here will be useless (unless you also use and need a TOP X clause) see below on where you have to put the ORDER BY
set nocount on
insert into @c (code)
SELECT Code FROM
WHERE (Optio_Concat IS NULL)
and Code is not null
-- process, either if the above insert did at least 1 row, or if the below "delete" did indeed
while @@ROWCOUNT <> 0
-- fetch 1 record from the table.
-- if your process requires some "order" in the processing, put the corresponding ORDER BY here
select top 1 @code= code from @c
if @@ROWCOUNT <> 0
exec Optio_Concat @code
-- here we delete the row from the temp table , which is nothing else than a processing queue table, hence
delete @c where code = @code
END -- end of loop
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.