DECLARE @sql nvarchar(4000) ... --SET @RowCount = (SELECT COUNT (*) FROM @TableName) SET @sql = 'SELECT @RowCount = COUNT (*) FROM ' + @TableName EXEC sp_executesql @sql, N'@RowCount int OUTPUT', @RowCount OUTPUT>I am trying to create a DB design document for a legacy DB. Part of this is the row count of each table. I have put together the following query, but it chokes at the line indicated (inside the cursor).
> SET @RowCount = (SELECT COUNT (*) FROM @TableName) >>