I have a bunch of variable values that i need to combine with the result set of dynamic sql and store/insert them in a table. Currently what i am doing is storing the dynamic result set in a temp table and combine there after but it is very inefficient and unnecessary I/O overhead. Any suggestions?
DECLARE @A NVARCHAR(20)='black'
DECLARE @B NVARCHAR(20)='Orange'
insert into #C
EXECUTE sp_executesql @Sql
SELECT @A, C.colA,@B,C.colB FROM #C? -- this is inefficient? Any better ideas?