I must admit, though, there is absolutely no need for the dynamic SQL...
DECLARE @TableNameSYSNAME
SET @TableName = 'dbo.JBMTest' --LOOK!!!! CHANGE THE TABLE NAME!!!!
SELECT TOP 1 [Rows] FROM sys.Partitions WHERE Object_ID = OBJECT_ID(@TableName)
--Jeff Moden
Change is inevitable... Change for the better is not.