I have an stupid question about output.
I have an stored procedure that inside is doing a dynamic SQL for checking if there are records in a table, this is the example:
SET @sqlLog =
'SELECT 1 FROM MyTable
WHERE TableName = ''' + @TableName + '''' + '
AND TheKey = ''' + convert(varchar(50), @LoadGuid) + ''''
EXEC(@sqlLog)
After that I’m using @@RowCount to validate if the result is 0 or not.
The problem is that is inside a WHILE and for each row is showing the result in the output window of SQL Management Studio and I don’t really want this.
Any idea? Thank you!
Why do you even need dynamic SQL for this?, you could do something like the following: