• This one does not need a temp table

    USE PUBS

    DECLARE @STRnvarchar(200),

    @Parm nvarchar(20),

    @Cntint

    SET @STR = 'SELECT @Cnt= COUNT(*) FROM Authors'

    SET @Parm = '@Cnt int output'

    EXEC sp_executesql @STR , @Parm ,@Cnt OUT

    PRINT @Cnt