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 "I Win" FROM thetable WHERE DidWin = 1 AND Playername='Me'
IntelliSense says Wrong syntax near Select
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 ...
SQL SELECT statement can be used along with COUNT(*) function to count and display the data values. The COUNT(*) function represents the count of all rows present in the table (including the NULL and NON-NULL values).
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 ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With