How do I save the result of my exeuction into a variable? I want to save the integer given by the count into a variable
DECLARE @count INT
SET @sqlString = 'SELECT COUNT (DISTINCT process) FROM @tableName
+ ' WHERE process =''' + @process + '''' + 'AND stage ='
+ '''' + @varStage+ ''''
PRINT @sqlString
SET @count = EXEC (@sqlString)
This is my idea, but the last line does not work.