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-2 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?