sql - Passing temp table from one execution to another -
i want pass temp table 1 execution path 1 nested in side
what have tried this:
declare @sqlquery nvarchar(max) set @sqlquery = ' --populate #temptable values execute('select top (100) * ' + tempdb..#temptable) execute sp_executesql @sqlquery
but fails error message:
incorrect syntax near 'tempdb'
is there another\better way pass temporary table between execution contexts?
your temp table visible inside dynamic sql no problem. not sure if creating temp table inside dynamic sql or before.
here table created before dynamic sql.
create table #temp(somevalue varchar(10)) insert #temp select 'made it' exec sp_executesql n'select * #temp'
Comments
Post a Comment