Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 xp_cmdshell behaves differently in UDF

Author  Topic 

Rajeswari
Starting Member

20 Posts

Posted - 2001-12-04 : 06:27:38
As specified in BOL, xp_cmdshell stored procedure works synchronously inside the stored procedure, but if it is used in user-defined functions,(if i run DOS commands like, copy file1+file2 file3, del file1, del file2 continuosly), it seems like asynchronous mode, What's the problem with user-defiend function.

manishrawat
Starting Member

9 Posts

Posted - 2001-12-07 : 11:21:24
yeah i found this in BOL.

Why does my SQL statement work correctly outside of a user-defined function, but incorrectly inside it?

Answer:

You may have included a statement in the BEGIN-END block that has side effects, which is not allowed in user-defined functions. Function side effects are any permanent changes to the state of a resource that has a scope outside the function. Changes can be made only to local objects such as local cursors or variables. Examples of actions that cannot be performed in a function include modifications to database tables, operations on cursors that are not local to the function, sending e-mail, attempting a catalog modification, and generating a result set that is returned to the user.

Go to Top of Page
   

- Advertisement -