Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Unanswered: 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 !

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Yes, in your function you need to do a:
    Code:
    INSERT INTO @table EXECUTE master.dbo.xp_test  -- and any parameters
    BEWARE: 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

  3. #3
    Join Date
    Mar 2004
    Posts
    2

    UDF

    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:
    Code:
    INSERT INTO @table 
    EXECUTE master.dbo.xp_test  -- and any parameters
    BEWARE: 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

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    So it runs, but no rows are inserted and no error is raised ???

    -PatP

  5. #5
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    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
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •