<<<snip>>>
>>Try this
>>
>>SET @sqlcmd = 'SELECT
[@NumRecs
] = COUNT(email)
>>FROM ' + @TableName
>>WHERE Include = 'Y'
>
>That certainly works Sergey. However, the PRINT @MyNumber line does not print a value. That means that the value (@NumRecs) was not returned to the calling program properly.
I just try it on my SQL Server and it works.
What version of SQL Server are you using?
My is 7.0
--sb--