5

I have an output parameter @Counter and a temporary table #tmpUsers

Is it possible to assign the value of

SELECT COUNT(*) FROM #tmpUsers

To the @Counter output parameter?

I have tried

SET @Counter = SELECT COUNT(*) FROM #tmpUsers

But this doesn't work for me

Win
  • 2,593
  • 3
  • 25
  • 35

1 Answers1

14

Try this way:

SELECT @Counter = COUNT(*) 
FROM #tmpUsers

or

SET @Counter = (SELECT COUNT(*) FROM #tmpUsers)
Robert
  • 25,425
  • 8
  • 67
  • 81