I'm writing some dynamic SQL in SQL Server. There are a few queries combined into one. The first query selects data, the second deletes, the third inserts, and the last deletes a temp table:
SET @completeSQL = @tempProdSQL + @deleteSQL + @insertSQL + ' DROP TABLE #tempProd'
PRINT(@completeSQL)
EXEC sp_ExecuteSQL @completeSQL
SET @archiveSize = @@ROWCOUNT
I know that I can use @@Rowcount
, but I'm getting a value of 0. I believe this is because the last command is to drop the table.
Is there a way to get the rows affected after the @tempProdSQL
command? I would prefer to not separate the execution if it will impact performance.
Aucun commentaire:
Enregistrer un commentaire