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