Iterate through rows in SQL Server 2008

Viewed 63915

Consider the table SAMPLE:

id       integer
name     nvarchar(10)

There is a stored proc called myproc. It takes only one paramater ( which is id)

Given a name as parameter, find all rows with the name = @nameparameter and pass all those ids to myproc

eg:

sample->
1   mark
2   mark
3   stu
41  mark

When mark is passed, 1 ,2 and 41 are to be passed to myproc individually.

i.e. the following should happen:

execute myproc 1
execute myproc 2
execute myproc 41

I can't touch myproc nor see its content. I just have to pass the values to it.

3 Answers
Related