sp_addlinkedserver @server='self', @srvproduct='',
@provider='SQLOLEDB', @datasrc=@@SERVERNAME
go
-- You have to explictly allow rpcs to and from your server
-- to get the exec call to work. This may have security implications,
-- consider yourself forewarned. If you run this whole script, 'self'
-- is dropped here in a sec anyway, so no big deal.
sp_serveroption 'self', 'rpc', 'on'
go
sp_serveroption 'self', 'rpc out', 'on'
go
-- make sure you use the fully qualified name
-- inside the OpenQuery statement
select * into NewTable
from OpenQuery(self, 'self.MyDB..MyProc 5')
go
sp_dropserver 'self'
go
select * from NewTable