Home Forums SQL Server 2005 T-SQL (SS2K5) Calling a stored procedure from within a function RE: Calling a stored procedure from within a function

  • hello,

    i hope that you found the answer to your question. but you still haven' t found it here is a possible solution:

    you can actually call a sp from an udf by using the openquery(). the trick is that you can use openquery within a udf and sql do not parse the character string that you give as parameter to the openquery and the best thing is that you can refer to your own server when using openquery. to be able to do so you have to execute the following script:

    EXEC sp_serveroption [server_name], 'Data Access', true
    and here is an example how to call sp with openquery:
    select * from openquery(MyServer, 'exec sp_who')go
    if you post more details about what you are trying to do with your
    udf a more elegant and straightforward way could be found but i hope
    this helps