Not sure what you mean by "not putting all the stuff in a variable." However, I have a solution, although it may go against what I think you mean. But it doesn’t matter here.
DECLARE @SQL VARCHAR(MAX)
SET @SQL = ''
SELECT
@SQL = @SQL + 'EXEC SprocName ''' + ColumnName + ''''
FROM
MyTable
EXEC (@SQL)
I use this method all the time when I need to execute sproc based on specific values from a table.
source
share