I have a case of executing stored procedures in SQL Server.
This may be an unusual practice, but I kept the list of stored procedure names in a table. The table is something like this (let's call it TableFoo ):
| SPId | SPName | ------------------- | 1 | spr_name1| | 2 | spr_name2| | 3 | spr_name3| | 4 | spr_name4| ...
I want to call / execute the list of stored procedure generated from the query result on TableFoo , the query is something like this:
SELECT SPName FROM TableFoo WHERE SPId IN (1, 2, 3)
I want to execute stored procedures sequentially in a string
I want to say that I want to do this :)
SELECT EXEC(SpName) FROM TableFoo WHERE SPId IN (1, 2, 3)
but it does not work
Is this any solution other than using CURSOR ?
Thanks in advance.
source share