Sunday, February 19, 2012

Help me please ! My question for an expert !

Hi !
I have been worked with VC++, MS SQL SERVER, Transact-SQL for
3 years. I made an axtended stored procedure (xp_test) which returns
an recordset.
From Query Analizer, I can see the recordest : exec xp_test

I want to make an User Defined Function - MyTest which return
the recordset that it is returned by xp_test after its execution.
Something like that :

CREATE function dbo.MyTest ( )
RETURNS @.table ...
AS
BEGIN
exec master.. xp_test table1 output -- can I do this ?

RETURN table1
END

Table and table1 are the same design.

Thank you very much !Yes, in your function you need to do a:INSERT INTO @.table EXECUTE master.dbo.xp_test -- and any parametersBEWARE: Non-deterministic code of any kind in your extended stored procedure can cause serious problems. Although it is highly unlikely, it is possible to even stop the SQL service!!!

-PatP|||For me it doesn't work :

INSERT INTO @.table EXECUTE master.dbo.xp_test

Originally posted by Pat Phelan
Yes, in your function you need to do a:INSERT INTO @.table
EXECUTE master.dbo.xp_test -- and any parametersBEWARE: Non-deterministic code of any kind in your extended stored procedure can cause serious problems. Although it is highly unlikely, it is possible to even stop the SQL service!!!

-PatP|||So it runs, but no rows are inserted and no error is raised ?

-PatP|||I was under the impression that you can not use execute inside a UDF except for calling extended stored procedures. Will have to check that Out ... Need to get back to the Holy Book

No comments:

Post a Comment