Calling a stored procedure from a select???

  • Hi all,

    I'm trying to update a column on with the results of stored procedure. I'm trying to do something like this:

    update pubs

    set booktitle = (exec USP_BuildBookTitleFromTempTable)

    where booktitleID =12

     

    Can someone please tell me the correct syntax to accomplish this??

     

    Thanks

     

  • Use User Defined Functions instead of Stored Procedure

  • Thanks but i need to used temp tbls which cannot be done inside a  udf

  • replace your temporary tables with table data type, which is allowed in UDF's

  • Can you show use the sp code so that we can provide an alternate solution?

  • Converting my temp tables to the table datatype and using a UDF instead worked!! Although i could have swore there is a way to invoke a sproc inside a update/select statement... hmmm... perhaps i was huffing too many paint cans that day

  • If you create a perm table and 2 users run the sp at the same time you'll get a error...

    Still waiting to see that code...

  • You can try this one :

    -- start here

    declare @output_param <data type>

    exec BuildBookTitleFromTempTable @output_param output -- I'm assumming that you will modify ur sproc to include output param

    update pubs

    set booktitle = @output_param

    where booktitleID =12

    -- end

    Ignas

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply