Assign a variable the number of rows a table has in SQL Server

How would you assign a variable the total number of rows in which a table has a SQL Server value?

+6
source share
2 answers

Something like the following should do the trick:

 Declare @VariableName int Select @VariableName=count(1) from TableName 
+16
source

SELECT COUNT(*) FROM Table

For more information, please provide more information.

0
source

Source: https://habr.com/ru/post/887400/


All Articles