Home:ALL Converter>How to call a stored procedure from a user defined function In SQL Server 2000

How to call a stored procedure from a user defined function In SQL Server 2000

Ask Time:2009-07-02T03:23:32         Author:Greens

Json Formatter

How to call a stored procedure from a user defined function in SQL Server 2000

Author:Greens,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/1070871/how-to-call-a-stored-procedure-from-a-user-defined-function-in-sql-server-2000
Arnkrishn :

Either you need to modify your stored procedure to be a user defined function or the other way around.\n\nOne crude way to achieve what you are looking for is to have your exec statement in a batch script and call that batch script from your function. Something like this:\n\ncreate function <functionName>\nexec master.sys.xp_cmpshell 'C:\\storedProc.bat'\n....\n....\n\nreturn @return\nend\n\n\nMore on xp_cmpshell on MSDN.",
2009-07-01T19:39:21
Scott Ivey :

You can't call regular stored procs from functions - only other functions or some extended stored procedures. See here for the BOL article (from SQL 2005). Attempting to call a standard stored proc from a UDF will result in the following error...\n\nMsg 557, Level 16, State 2, Line 1\nOnly functions and some extended stored procedures can be executed from within a function.",
2009-07-01T19:32:21
yy