tags:

views:

12

answers:

0

Getting the results sets via OpenQuery when the underlying proc creates/deletes or inserts into a table is acting funny:

Sample proc:

create procedure test_VanishingTables
 as


create table zTableThatVanishes
(
    Value1 int,
    Value2 varchar(255)
)

IF  not exists (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[zTableThatVanishes]') AND type in (N'U'))
begin
    raiserror('Table not created', 16, 1)
    return
end
else
begin
    print 'table Created'
end

 insert into zTableThatVanishes values (1, 'this')
 insert into zTableThatVanishes values (1, 'that')

select * from zTableThatVanishes

drop table zTableThatVanishes

Code snippets that don't work

SELECT  * FROM    OPENQUERY([SDFSTAGESQL01\SQLSTAGE1], 'EXEC rccore.dbo.test_VanishingTables')

SELECT  * FROM    OPENQUERY([SDFSTAGESQL01\SQLSTAGE1], 'SET FMTONLY OFF; EXEC rccore.dbo.test_VanishingTables')

Code snippet that does work

exec rccore.dbo.test_VanishingTables

Thanks in advance