• Eric M Russell (12/14/2011)


    I think more explanation is needed about what your script is demonstrating. Is your specific intent to demonstrate how to select from a "remote" stored procedure?

    When I want to return a filtered or transformed result from a stored procedure, I will insert into a table variable or temp table like so. This seems cleaner, because it required no connection string.

    create procedure dbo.proc_simple as

    select top 5 object_id, name from sys.objects

    go

    declare @objects table ( obj_id int, obj_name varchar(180) );

    insert into @objects ( obj_id, obj_name )

    exec dbo.proc_simple;

    select * from @objects;

    obj_id obj_name

    ----------- --------------------

    4 sysrowsetcolumns

    5 sysrowsets

    7 sysallocunits

    8 sysfiles1

    13 syshobtcolumns

    +1

    This is the way I do it. Then you have a table you can join with too if necessary.