I've the query below:
select * from tblA
This tblA have column ID and NAME
I want get the ID's from this table and use into a procedure.
I.E:
exec spGet ID
This is a loop, right?
How I can do this?
Tnks.
I've the query below:
select * from tblA
This tblA have column ID and NAME
I want get the ID's from this table and use into a procedure.
I.E:
exec spGet ID
This is a loop, right?
How I can do this?
Tnks.
If you really want to do it this way, you can use a cursor, but I'd strongly suggest to rethink what you're doing.
DECLARE @ID INT;
DECLARE curIteration CURSOR
FOR
SELECT ID
FROM tblA;
OPEN curIteration
FETCH NEXT FROM curIteration
INTO @ID;
WHILE @@FETCH_STATUS = 0
BEGIN
EXECUTE spGet @ID;
FETCH NEXT FROM curIteration
INTO @ID;
END
CLOSE curIteration;
DEALLOCATE curIteration;