I'm trying to count the number of rows in a table whose name is a variable; for exmple @TableName
I'm trying to achieve something like this:
DECLARE @cnt int
SELECT @cnt = COUNT(*) FROM @Table WHERE Word='word'
Could anybody advise of the best way to do this?