• I do not think that that is right, Adam. Try executing the following:SET NOCOUNT ON

    create table #temp(foo int)

    Insert into #temp select 13

    Declare @Sql Nvarchar(max)

    SET @Sql = 'SELECT * FROM #temp '

    EXEC(@sql)

    EXEC sp_ExecuteSql @sql

    GO

    drop table #temp

    It returns the following output:foo

    -----------

    13

    foo

    -----------

    13

    Which seems to indicate that the #Temp table is visible and usable form both the EXEC(string) and sp_ExecuteSql() subordinate batches.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]