sql set variable using COUNT

后端 未结 4 1777
陌清茗
陌清茗 2021-02-04 23:50

I am trying to make a simple query to my server and want the result to be stored in the variable @times.

DECLARE @times int

SET @times = SELECT COUNT(DidWin)as          


        
4条回答
  •  日久生厌
    2021-02-05 00:10

    You just need parentheses around your select:

    SET @times = (SELECT COUNT(DidWin) FROM ...)
    

    Or you can do it like this:

    SELECT @times = COUNT(DidWin) FROM ...
    

提交回复
热议问题