create table tablenameA(n int)

-------------------------------------------

declare @tablename sysname,@sql nvarchar(4000),@ret int

set @tablename = 'tablenameA'
set @sql = N'select @r = count(*) from ' + @tablename
exec sp_executesql @sql,N'@r int output',@r = @ret output

select @ret

/*
------------
0
(1 적용됨)
*/

Posted by Sting!
,