0

I have a dynamic sql statement that runs on a remote linked server. I can run the statement like this

exec (@sql) at MylinkedServer

The data comes back ok, but that's where the issue starts. I can't seem to do anything locally with the result set. I can't insert it into a local table or a temp table.

Eg:

insert into #results exec(@sql) at DC105WCSV712

Can some one show me how this could be achieved ?

ErickTreetops
  • 3,189
  • 4
  • 27
  • 37

1 Answers1

0

if your getting a single return variable you can do:

declare @localVariable int
exec @localVariable =GetMyValue
select @localVariable

And then

insert the @localVariable in your table

Albert Laure
  • 1,702
  • 5
  • 20
  • 49